vendor/shopware/core/Content/Category/Tree/TreeItem.php line 8

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Category\Tree;
  3. use Shopware\Core\Content\Category\CategoryEntity;
  4. use Shopware\Core\Framework\Struct\Struct;
  5. class TreeItem extends Struct
  6. {
  7.     /**
  8.      * @internal public to allow AfterSort::sort()
  9.      */
  10.     public ?string $afterId;
  11.     /**
  12.      * @var CategoryEntity
  13.      */
  14.     protected $category;
  15.     /**
  16.      * @var TreeItem[]
  17.      */
  18.     protected $children;
  19.     public function __construct(?CategoryEntity $category, array $children)
  20.     {
  21.         $this->category $category;
  22.         $this->children $children;
  23.         $this->afterId $category $category->getAfterCategoryId() : null;
  24.     }
  25.     public function getId(): string
  26.     {
  27.         return $this->category->getId();
  28.     }
  29.     public function setCategory(CategoryEntity $category): void
  30.     {
  31.         $this->category $category;
  32.         $this->afterId $category->getAfterCategoryId();
  33.     }
  34.     public function getCategory(): CategoryEntity
  35.     {
  36.         return $this->category;
  37.     }
  38.     public function getChildren(): array
  39.     {
  40.         return $this->children;
  41.     }
  42.     public function addChildren(TreeItem ...$items): void
  43.     {
  44.         foreach ($items as $item) {
  45.             $this->children[] = $item;
  46.         }
  47.     }
  48.     public function setChildren(array $children): void
  49.     {
  50.         $this->children $children;
  51.     }
  52.     public function getApiAlias(): string
  53.     {
  54.         return 'category_tree_item';
  55.     }
  56. }