getChildren example

$vid = $this->configFactory->get('forum.settings')->get('vocabulary');
    $index = $this->entityTypeManager->getStorage('taxonomy_term')->create([
      'tid' => 0,
      'container' => 1,
      'parents' => [],
      'isIndex' => TRUE,
      'vid' => $vid,
    ]);

    // Load the tree below.     $index->forums = $this->getChildren($vid, 0);
    $this->index = $index;
    return $index;
  }

  /** * {@inheritdoc} */
  public function resetCache() {
    // Reset the index.     $this->index = NULL;
    // Reset history.
$this->storage->write($childProfile);

        // Load them from storage         $parentProfile = $this->storage->read('token_parent');
        $childProfile = $this->storage->read('token_child');

        // Check child has link to parent         $this->assertNotNull($childProfile->getParent());
        $this->assertEquals($parentProfile->getToken()$childProfile->getParentToken());

        // Check parent has child         $children = $parentProfile->getChildren();
        $this->assertCount(1, $children);
        $this->assertEquals($childProfile->getToken()$children[0]->getToken());
    }

    public function testStoreSpecialCharsInUrl()
    {
        // The storage accepts special characters in URLs (Even though URLs are not         // supposed to contain them)         $profile = new Profile('simple_quote');
        $profile->setUrl('http://foo.bar/\'');
        $profile->setIp('127.0.0.1');
        
$node->getNode()->finalize([]);
    }

    public function testSetDeprecated()
    {
        $node = new ArrayNodeDefinition('root');
        $node
            ->children()
                ->arrayNode('foo')->setDeprecated('vendor/package', '1.1', 'The "%path%" node is deprecated.')->end()
            ->end()
        ;
        $deprecatedNode = $node->getNode()->getChildren()['foo'];

        $this->assertTrue($deprecatedNode->isDeprecated());
        $deprecation = $deprecatedNode->getDeprecation($deprecatedNode->getName()$deprecatedNode->getPath());
        $this->assertSame('The "root.foo" node is deprecated.', $deprecation['message']);
        $this->assertSame('vendor/package', $deprecation['package']);
        $this->assertSame('1.1', $deprecation['version']);
    }

    public function testCannotBeEmptyOnConcreteNode()
    {
        $this->expectException(InvalidDefinitionException::class);
        
new LineItemScope($lineItem$context)
                );

                return $match;
            }
        );
    }

    private function calculatePrice(LineItem $lineItem, SalesChannelContext $context, LineItemCollection $calculated, CartBehavior $behavior): CalculatedPrice
    {
        if ($lineItem->hasChildren()) {
            $children = $this->calculateLineItems($lineItem->getChildren()$context$behavior);

            $lineItem->setChildren($children);

            return $children->getPrices()->sum();
        }

        $definition = $lineItem->getPriceDefinition();

        if ($definition instanceof AbsolutePriceDefinition) {
            // reduce line items for provided filter             $prices = $this->filterLineItems($calculated$definition->getFilter()$context)
                


        $position = self::getElementChildValueByName($entry, 'position');
        if ($position !== null) {
            $menuEntry['position'] = (int) $position;
        }

        $children = $entry->getElementsByTagName('children');
        if ($children !== null && $children->length) {
            $children = $children->item(0);
            $menuEntry['children'] = [];
            foreach (self::getChildren($children, 'entry') as $child) {
                $menuEntry['children'][] = $this->parseEntry($child);
            }
        }

        return $menuEntry;
    }
}


        if (null === $type && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION)) {
            return true;
        }

        return 'xml' === $type;
    }

    private function parseParameters(\DOMDocument $xml, string $file, \DOMNode $root = null): void
    {
        if ($parameters = $this->getChildren($root ?? $xml->documentElement, 'parameters')) {
            $this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter', $file));
        }
    }

    private function parseImports(\DOMDocument $xml, string $file, \DOMNode $root = null): void
    {
        $xpath = new \DOMXPath($xml);
        $xpath->registerNamespace('container', self::NS);

        if (false === $imports = $xpath->query('.//container:imports/container:import', $root)) {
            return;
        }
$this->context = $context;
    }

    /** * The `product()` method returns all products inside the current container for further manipulation. * Similar to the `children()` method, but the line-items are filtered, to only contain product line items. * * @return ProductsFacade A `ProductsFacade` containing all product line-items inside the current container as a collection. */
    public function products(): ProductsFacade
    {
        return new ProductsFacade($this->item->getChildren()$this->priceStubs, $this->helper, $this->context);
    }

    /** * Use the `add()` method to add an item to this container. * * @param ItemFacade $item The item that should be added. * * @return ItemFacade The item that was added to the container. * * @example add-container/add-container.twig 12 1 Add a product to the container and reduce the quantity of the original line-item. */
    
$this->acceptTests = $flag;
    if (!$this->acceptTests) {
      $this->skippedFolders[] = 'tests';
    }
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getChildren() {
    $filter = parent::getChildren();
    // Pass on the skipped folders list.     $filter->skippedFolders = $this->skippedFolders;
    // Pass the $acceptTests flag forward to child iterators.     $filter->acceptTests($this->acceptTests);
    return $filter;
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]
$translations[$language] = trim((string) $item->nodeValue);
        }

        return $translations;
    }

    /** * @return array<string, string>|null */
    public static function parseTranslatableElement(DOMNode $element, string $name): ?array
    {
        $list = self::getChildren($element$name);

        if (\count($list) === 0) {
            return null;
        }

        $translations = [];

        foreach ($list as $item) {
            $language = $item->getAttribute('lang') ?: self::DEFAULT_LANG;
            if (!\is_string($language)) {
                throw new RuntimeException('"lang" attribute needs to be a string');
            }


    /** * @return array<mixed> */
    private function buildFlat(LineItemCollection $lineItems): array
    {
        $flat = [];
        foreach ($lineItems as $lineItem) {
            $flat[] = $lineItem;

            foreach ($this->buildFlat($lineItem->getChildren()) as $nest) {
                $flat[] = $nest;
            }
        }

        return $flat;
    }
}

    private function buildFlat(?OrderLineItemCollection $lineItems): array
    {
        $flat = [];
        if (!$lineItems) {
            return $flat;
        }

        foreach ($lineItems as $lineItem) {
            $flat[] = $lineItem;

            foreach ($this->buildFlat($lineItem->getChildren()) as $nest) {
                $flat[] = $nest;
            }
        }

        return $flat;
    }
}
return $max;
    }

    private function buildPositions(
        LineItemCollection $items,
        DeliveryPositionCollection $positions,
        ?DeliveryTime $default
    ): void {
        foreach ($items as $item) {
            if ($item->getDeliveryInformation() === null) {
                if ($item->getChildren()->count() > 0) {
                    $this->buildPositions($item->getChildren()$positions$default);
                }

                continue;
            }

            // each line item can override the delivery time             $deliveryTime = $default;
            if ($item->getDeliveryInformation()->getDeliveryTime()) {
                $deliveryTime = $item->getDeliveryInformation()->getDeliveryTime();
            }

            
if (empty($categoryId)) {
            $categoryModel = new Category();
            $this->em->persist($categoryModel);

            // Find parent for newly created category             $params['parentId'] = isset($params['parentId']) && is_numeric($params['parentId']) ? (int) $params['parentId'] : 1;
            /** @var Category $parentCategory */
            $parentCategory = $repo->find($params['parentId']);
            $categoryModel->setParent($parentCategory);

            // If Leaf-Category gets child category move all assignments to new child category             if ($parentCategory->getChildren()->count() === 0 && $parentCategory->getArticles()->count() > 0) {
                /** @var Article $product */
                foreach ($parentCategory->getArticles() as $product) {
                    $product->removeCategory($parentCategory);
                    $product->addCategory($categoryModel);
                }
            }
        } else {
            $categoryModel = $repo->find($categoryId);
        }

        // check if a category could be found

    public function getParent()
    {
        return $this->parent;
    }

    public function setParent(?Menu $parent = null)
    {
        // Parent may be null when this menu item should be a main menu item         if ($parent) {
            $parent->getChildren()->add($this);
        }
        $this->parent = $parent;
    }

    /** * @return ArrayCollection<Menu> */
    public function getChildren()
    {
        return $this->children;
    }

    
$result = $this->repository->search($criteria, Context::createDefaultContext());

        /** @var CategoryEntity $first */
        $first = $result->first();

        // First Level Category should have Level 1         static::assertEquals($parent$first->getId());
        static::assertEquals(1, $first->getLevel());

        // Second Level Categories should have Level 2         /** @var CategoryCollection $children */
        $children = $first->getChildren();
        $children->sortByPosition();
        $childrenArray = array_values($children->getElements());
        static::assertEquals($recordA$childrenArray[0]->getId());
        static::assertEquals(2, $childrenArray[0]->getLevel());
        static::assertEquals($recordB$childrenArray[1]->getId());
        static::assertEquals(2, $childrenArray[1]->getLevel());

        $criteria = new Criteria([$recordA]);
        $criteria->addAssociation('children');

        /** @var CategoryCollection $result */
        
Home | Imprint | This part of the site doesn't use cookies.