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.      * @var CategoryEntity
  9.      */
  10.     protected $category;
  11.     /**
  12.      * @var TreeItem[]
  13.      */
  14.     protected $children;
  15.     public function __construct(?CategoryEntity $category, array $children)
  16.     {
  17.         $this->category $category;
  18.         $this->children $children;
  19.     }
  20.     public function setCategory(CategoryEntity $category): void
  21.     {
  22.         $this->category $category;
  23.     }
  24.     public function getCategory(): CategoryEntity
  25.     {
  26.         return $this->category;
  27.     }
  28.     public function getChildren(): array
  29.     {
  30.         return $this->children;
  31.     }
  32.     public function addChildren(TreeItem ...$items): void
  33.     {
  34.         foreach ($items as $item) {
  35.             $this->children[] = $item;
  36.         }
  37.     }
  38.     public function setChildren(array $children): void
  39.     {
  40.         $this->children $children;
  41.     }
  42.     public function getApiAlias(): string
  43.     {
  44.         return 'category_tree_item';
  45.     }
  46. }