vendor/sulu/sulu/src/Sulu/Bundle/CategoryBundle/Entity/Category.php line 21

  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Bundle\CategoryBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Sulu\Component\Security\Authentication\UserInterface;
  14. /**
  15.  * Category.
  16.  */
  17. class Category implements CategoryInterface
  18. {
  19.     /**
  20.      * @var int
  21.      */
  22.     protected $lft;
  23.     /**
  24.      * @var int
  25.      */
  26.     protected $rgt;
  27.     /**
  28.      * @var int
  29.      */
  30.     protected $depth;
  31.     /**
  32.      * @var \DateTime
  33.      */
  34.     protected $created;
  35.     /**
  36.      * @var \DateTime
  37.      */
  38.     protected $changed;
  39.     /**
  40.      * @var int
  41.      */
  42.     protected $id;
  43.     /**
  44.      * @var string|null
  45.      */
  46.     protected $key;
  47.     /**
  48.      * @var string
  49.      */
  50.     protected $defaultLocale;
  51.     /**
  52.      * @var CategoryInterface|null
  53.      */
  54.     protected $parent;
  55.     /**
  56.      * @var UserInterface|null
  57.      */
  58.     protected $creator;
  59.     /**
  60.      * @var UserInterface|null
  61.      */
  62.     protected $changer;
  63.     /**
  64.      * @var Collection<int, CategoryMetaInterface>
  65.      */
  66.     protected $meta;
  67.     /**
  68.      * @var Collection<int, CategoryTranslationInterface>
  69.      */
  70.     protected $translations;
  71.     /**
  72.      * @var Collection<int, CategoryInterface>
  73.      */
  74.     protected $children;
  75.     /**
  76.      * Constructor.
  77.      */
  78.     public function __construct()
  79.     {
  80.         $this->meta = new ArrayCollection();
  81.         $this->translations = new ArrayCollection();
  82.         $this->children = new ArrayCollection();
  83.     }
  84.     public function setId($id)
  85.     {
  86.         $this->id $id;
  87.         return $this;
  88.     }
  89.     public function setLft($lft)
  90.     {
  91.         $this->lft $lft;
  92.         return $this;
  93.     }
  94.     public function getLft()
  95.     {
  96.         return $this->lft;
  97.     }
  98.     public function setRgt($rgt)
  99.     {
  100.         $this->rgt $rgt;
  101.         return $this;
  102.     }
  103.     public function getRgt()
  104.     {
  105.         return $this->rgt;
  106.     }
  107.     public function setDepth($depth)
  108.     {
  109.         $this->depth $depth;
  110.         return $this;
  111.     }
  112.     public function getDepth()
  113.     {
  114.         return $this->depth;
  115.     }
  116.     public function getCreated()
  117.     {
  118.         return $this->created;
  119.     }
  120.     public function getKey()
  121.     {
  122.         return $this->key;
  123.     }
  124.     public function setKey($key)
  125.     {
  126.         $this->key $key;
  127.         return $this;
  128.     }
  129.     public function setDefaultLocale($defaultLocale)
  130.     {
  131.         $this->defaultLocale $defaultLocale;
  132.         return $this;
  133.     }
  134.     public function getDefaultLocale()
  135.     {
  136.         return $this->defaultLocale;
  137.     }
  138.     public function getChanged()
  139.     {
  140.         return $this->changed;
  141.     }
  142.     public function getId()
  143.     {
  144.         return $this->id;
  145.     }
  146.     public function setParent(CategoryInterface $parent null)
  147.     {
  148.         $this->parent $parent;
  149.         return $this;
  150.     }
  151.     public function getParent()
  152.     {
  153.         return $this->parent;
  154.     }
  155.     public function setCreator(UserInterface $creator null)
  156.     {
  157.         $this->creator $creator;
  158.         return $this;
  159.     }
  160.     public function setCreated(\DateTime $created)
  161.     {
  162.         $this->created $created;
  163.         return $this;
  164.     }
  165.     public function getCreator()
  166.     {
  167.         return $this->creator;
  168.     }
  169.     public function setChanger(UserInterface $changer null)
  170.     {
  171.         $this->changer $changer;
  172.         return $this;
  173.     }
  174.     public function setChanged(\DateTime $changed)
  175.     {
  176.         $this->changed $changed;
  177.         return $this;
  178.     }
  179.     public function getChanger()
  180.     {
  181.         return $this->changer;
  182.     }
  183.     public function addMeta(CategoryMetaInterface $meta)
  184.     {
  185.         $this->meta[] = $meta;
  186.         return $this;
  187.     }
  188.     public function removeMeta(CategoryMetaInterface $meta)
  189.     {
  190.         $this->meta->removeElement($meta);
  191.     }
  192.     public function getMeta()
  193.     {
  194.         return $this->meta;
  195.     }
  196.     public function addTranslation(CategoryTranslationInterface $translations)
  197.     {
  198.         $this->translations[] = $translations;
  199.         return $this;
  200.     }
  201.     public function removeTranslation(CategoryTranslationInterface $translations)
  202.     {
  203.         $this->translations->removeElement($translations);
  204.     }
  205.     public function getTranslations()
  206.     {
  207.         return $this->translations;
  208.     }
  209.     public function findTranslationByLocale($locale)
  210.     {
  211.         return $this->translations->filter(
  212.             function(CategoryTranslationInterface $translation) use ($locale) {
  213.                 return $translation->getLocale() === $locale;
  214.             }
  215.         )->first();
  216.     }
  217.     public function addChildren(CategoryInterface $child)
  218.     {
  219.         @trigger_deprecation('sulu/sulu''1.4'__METHOD__ '() is deprecated and will be removed in 2.0. Use addChild() instead.');
  220.         $this->addChild($child);
  221.     }
  222.     public function addChild(CategoryInterface $child)
  223.     {
  224.         $this->children[] = $child;
  225.         return $this;
  226.     }
  227.     public function removeChildren(CategoryInterface $child)
  228.     {
  229.         @trigger_deprecation('sulu/sulu''1.4'__METHOD__ '() is deprecated and will be removed in 2.0. Use removeChild() instead.');
  230.         $this->removeChild($child);
  231.     }
  232.     public function removeChild(CategoryInterface $child)
  233.     {
  234.         $this->children->removeElement($child);
  235.     }
  236.     public function getChildren()
  237.     {
  238.         return $this->children;
  239.     }
  240. }