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