vendor/sulu/sulu/src/Sulu/Bundle/MediaBundle/Entity/Collection.php line 23

Open in your IDE?
  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\MediaBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection as DoctrineCollection;
  13. use JMS\Serializer\Annotation\Exclude;
  14. use Sulu\Bundle\SecurityBundle\Entity\PermissionInheritanceInterface;
  15. use Sulu\Component\Security\Authentication\UserInterface;
  16. /**
  17.  * Collection.
  18.  */
  19. class Collection implements CollectionInterfacePermissionInheritanceInterface
  20. {
  21.     /**
  22.      * @var int
  23.      */
  24.     protected $id;
  25.     /**
  26.      * @var string|null
  27.      */
  28.     protected $style;
  29.     /**
  30.      * @var int
  31.      * @Exclude
  32.      */
  33.     protected $lft;
  34.     /**
  35.      * @var int
  36.      * @Exclude
  37.      */
  38.     protected $rgt;
  39.     /**
  40.      * @var int
  41.      * @Exclude
  42.      */
  43.     protected $depth;
  44.     /**
  45.      * @var \DateTime
  46.      */
  47.     protected $created;
  48.     /**
  49.      * @var \DateTime
  50.      */
  51.     protected $changed;
  52.     /**
  53.      * @var CollectionType
  54.      */
  55.     protected $type;
  56.     /**
  57.      * @var UserInterface|null
  58.      * @Exclude
  59.      */
  60.     protected $changer;
  61.     /**
  62.      * @var UserInterface|null
  63.      * @Exclude
  64.      */
  65.     protected $creator;
  66.     /**
  67.      * @var string|null
  68.      */
  69.     private $key;
  70.     /**
  71.      * @var DoctrineCollection<int, CollectionMeta>
  72.      */
  73.     private $meta;
  74.     /**
  75.      * @var DoctrineCollection<int, MediaInterface>
  76.      * @Exclude
  77.      */
  78.     private $media;
  79.     /**
  80.      * @var DoctrineCollection<int, CollectionInterface>
  81.      */
  82.     private $children;
  83.     /**
  84.      * @var CollectionInterface|null
  85.      */
  86.     private $parent;
  87.     /**
  88.      * @var CollectionMeta
  89.      */
  90.     private $defaultMeta;
  91.     public function __construct()
  92.     {
  93.         $this->meta = new ArrayCollection();
  94.         $this->media = new ArrayCollection();
  95.         $this->children = new ArrayCollection();
  96.     }
  97.     /**
  98.      * Get id.
  99.      *
  100.      * @return int
  101.      */
  102.     public function getId()
  103.     {
  104.         return $this->id;
  105.     }
  106.     /**
  107.      * Set changer.
  108.      *
  109.      * @return CollectionInterface
  110.      */
  111.     public function setChanger(UserInterface $changer null)
  112.     {
  113.         $this->changer $changer;
  114.         return $this;
  115.     }
  116.     /**
  117.      * Get changer.
  118.      *
  119.      * @return UserInterface|null
  120.      */
  121.     public function getChanger()
  122.     {
  123.         return $this->changer;
  124.     }
  125.     /**
  126.      * Set creator.
  127.      *
  128.      * @return CollectionInterface
  129.      */
  130.     public function setCreator(UserInterface $creator null)
  131.     {
  132.         $this->creator $creator;
  133.         return $this;
  134.     }
  135.     /**
  136.      * Get creator.
  137.      *
  138.      * @return UserInterface|null
  139.      */
  140.     public function getCreator()
  141.     {
  142.         return $this->creator;
  143.     }
  144.     /**
  145.      * Set style.
  146.      *
  147.      * @param string|null $style
  148.      *
  149.      * @return CollectionInterface
  150.      */
  151.     public function setStyle($style)
  152.     {
  153.         $this->style $style;
  154.         return $this;
  155.     }
  156.     /**
  157.      * Get style.
  158.      *
  159.      * @return string|null
  160.      */
  161.     public function getStyle()
  162.     {
  163.         return $this->style;
  164.     }
  165.     /**
  166.      * Set lft.
  167.      *
  168.      * @param int $lft
  169.      *
  170.      * @return CollectionInterface
  171.      */
  172.     public function setLft($lft)
  173.     {
  174.         $this->lft $lft;
  175.         return $this;
  176.     }
  177.     /**
  178.      * Get lft.
  179.      *
  180.      * @return int
  181.      */
  182.     public function getLft()
  183.     {
  184.         return $this->lft;
  185.     }
  186.     /**
  187.      * Set rgt.
  188.      *
  189.      * @param int $rgt
  190.      *
  191.      * @return CollectionInterface
  192.      */
  193.     public function setRgt($rgt)
  194.     {
  195.         $this->rgt $rgt;
  196.         return $this;
  197.     }
  198.     /**
  199.      * Get rgt.
  200.      *
  201.      * @return int
  202.      */
  203.     public function getRgt()
  204.     {
  205.         return $this->rgt;
  206.     }
  207.     /**
  208.      * Set depth.
  209.      *
  210.      * @param int $depth
  211.      *
  212.      * @return CollectionInterface
  213.      */
  214.     public function setDepth($depth)
  215.     {
  216.         $this->depth $depth;
  217.         return $this;
  218.     }
  219.     /**
  220.      * Get depth.
  221.      *
  222.      * @return int
  223.      */
  224.     public function getDepth()
  225.     {
  226.         return $this->depth;
  227.     }
  228.     /**
  229.      * Get created.
  230.      *
  231.      * @return \DateTime
  232.      */
  233.     public function getCreated()
  234.     {
  235.         return $this->created;
  236.     }
  237.     /**
  238.      * Get changed.
  239.      *
  240.      * @return \DateTime
  241.      */
  242.     public function getChanged()
  243.     {
  244.         return $this->changed;
  245.     }
  246.     /**
  247.      * Set type.
  248.      *
  249.      * @return CollectionInterface
  250.      */
  251.     public function setType(CollectionType $type)
  252.     {
  253.         $this->type $type;
  254.         return $this;
  255.     }
  256.     /**
  257.      * Get type.
  258.      *
  259.      * @return CollectionType
  260.      */
  261.     public function getType()
  262.     {
  263.         return $this->type;
  264.     }
  265.     /**
  266.      * Set key.
  267.      *
  268.      * @return string|null
  269.      */
  270.     public function getKey()
  271.     {
  272.         return $this->key;
  273.     }
  274.     /**
  275.      * Get key.
  276.      *
  277.      * @param string|null $key
  278.      *
  279.      * @return CollectionInterface
  280.      */
  281.     public function setKey($key)
  282.     {
  283.         $this->key $key;
  284.         return $this;
  285.     }
  286.     /**
  287.      * @return DoctrineCollection<int, self>
  288.      */
  289.     public function getChildren()
  290.     {
  291.         return $this->children;
  292.     }
  293.     public function setChildren(DoctrineCollection $children)
  294.     {
  295.         $this->children $children;
  296.     }
  297.     /**
  298.      * Set parent.
  299.      *
  300.      * @return CollectionInterface
  301.      */
  302.     public function setParent(CollectionInterface $parent null)
  303.     {
  304.         $this->parent $parent;
  305.         return $this;
  306.     }
  307.     /**
  308.      * Get parent.
  309.      *
  310.      * @return CollectionInterface|null
  311.      */
  312.     public function getParent()
  313.     {
  314.         return $this->parent;
  315.     }
  316.     /**
  317.      * @return int|null
  318.      */
  319.     public function getParentId()
  320.     {
  321.         if ($this->parent) {
  322.             return $this->parent->getId();
  323.         }
  324.         return null;
  325.     }
  326.     /**
  327.      * Add meta.
  328.      *
  329.      * @return Collection
  330.      */
  331.     public function addMeta(CollectionMeta $meta)
  332.     {
  333.         $this->meta[] = $meta;
  334.         return $this;
  335.     }
  336.     /**
  337.      * Remove meta.
  338.      *
  339.      * @return void
  340.      */
  341.     public function removeMeta(CollectionMeta $meta)
  342.     {
  343.         $this->meta->removeElement($meta);
  344.     }
  345.     /**
  346.      * Get meta.
  347.      *
  348.      * @return DoctrineCollection<int, CollectionMeta>
  349.      */
  350.     public function getMeta()
  351.     {
  352.         return $this->meta;
  353.     }
  354.     /**
  355.      * Add media.
  356.      *
  357.      * @return Collection
  358.      */
  359.     public function addMedia(MediaInterface $media)
  360.     {
  361.         $this->media[] = $media;
  362.         return $this;
  363.     }
  364.     /**
  365.      * Remove media.
  366.      *
  367.      * @return void
  368.      */
  369.     public function removeMedia(MediaInterface $media)
  370.     {
  371.         $this->media->removeElement($media);
  372.     }
  373.     /**
  374.      * Get media.
  375.      *
  376.      * @return DoctrineCollection<int, MediaInterface>
  377.      */
  378.     public function getMedia()
  379.     {
  380.         return $this->media;
  381.     }
  382.     /**
  383.      * Add children.
  384.      *
  385.      * @return Collection
  386.      */
  387.     public function addChildren(CollectionInterface $children)
  388.     {
  389.         $this->children[] = $children;
  390.         return $this;
  391.     }
  392.     /**
  393.      * Remove children.
  394.      *
  395.      * @return void
  396.      */
  397.     public function removeChildren(CollectionInterface $children)
  398.     {
  399.         $this->children->removeElement($children);
  400.     }
  401.     /**
  402.      * Set defaultMeta.
  403.      *
  404.      * @param CollectionMeta $defaultMeta
  405.      *
  406.      * @return Collection
  407.      */
  408.     public function setDefaultMeta(CollectionMeta $defaultMeta null)
  409.     {
  410.         $this->defaultMeta $defaultMeta;
  411.         return $this;
  412.     }
  413.     /**
  414.      * Get defaultMeta.
  415.      *
  416.      * @return CollectionMeta
  417.      */
  418.     public function getDefaultMeta()
  419.     {
  420.         return $this->defaultMeta;
  421.     }
  422.     public function getSecurityContext()
  423.     {
  424.         return 'sulu.media.collections';
  425.     }
  426. }