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 CollectionInterface, PermissionInheritanceInterface
  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. protected $lft;
  34. /**
  35. * @var int
  36. */
  37. #[Exclude]
  38. protected $rgt;
  39. /**
  40. * @var int
  41. */
  42. #[Exclude]
  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. */
  59. #[Exclude]
  60. protected $changer;
  61. /**
  62. * @var UserInterface|null
  63. */
  64. #[Exclude]
  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. */
  77. #[Exclude]
  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. * @return $this
  248. */
  249. public function setCreated(\DateTime $created)
  250. {
  251. $this->created = $created;
  252. return $this;
  253. }
  254. /**
  255. * @return $this
  256. */
  257. public function setChanged(\DateTime $changed)
  258. {
  259. $this->changed = $changed;
  260. return $this;
  261. }
  262. /**
  263. * Set type.
  264. *
  265. * @return CollectionInterface
  266. */
  267. public function setType(CollectionType $type)
  268. {
  269. $this->type = $type;
  270. return $this;
  271. }
  272. /**
  273. * Get type.
  274. *
  275. * @return CollectionType
  276. */
  277. public function getType()
  278. {
  279. return $this->type;
  280. }
  281. /**
  282. * Set key.
  283. *
  284. * @return string|null
  285. */
  286. public function getKey()
  287. {
  288. return $this->key;
  289. }
  290. /**
  291. * Get key.
  292. *
  293. * @param string|null $key
  294. *
  295. * @return CollectionInterface
  296. */
  297. public function setKey($key)
  298. {
  299. $this->key = $key;
  300. return $this;
  301. }
  302. /**
  303. * @return DoctrineCollection<int, self>
  304. */
  305. public function getChildren()
  306. {
  307. return $this->children;
  308. }
  309. public function setChildren(DoctrineCollection $children)
  310. {
  311. $this->children = $children;
  312. }
  313. /**
  314. * Set parent.
  315. *
  316. * @return CollectionInterface
  317. */
  318. public function setParent(?CollectionInterface $parent = null)
  319. {
  320. $this->parent = $parent;
  321. return $this;
  322. }
  323. /**
  324. * Get parent.
  325. *
  326. * @return CollectionInterface|null
  327. */
  328. public function getParent()
  329. {
  330. return $this->parent;
  331. }
  332. /**
  333. * @return int|null
  334. */
  335. public function getParentId()
  336. {
  337. if ($this->parent) {
  338. return $this->parent->getId();
  339. }
  340. return null;
  341. }
  342. /**
  343. * Add meta.
  344. *
  345. * @return Collection
  346. */
  347. public function addMeta(CollectionMeta $meta)
  348. {
  349. $this->meta[] = $meta;
  350. return $this;
  351. }
  352. /**
  353. * Remove meta.
  354. *
  355. * @return void
  356. */
  357. public function removeMeta(CollectionMeta $meta)
  358. {
  359. $this->meta->removeElement($meta);
  360. }
  361. /**
  362. * Get meta.
  363. *
  364. * @return DoctrineCollection<int, CollectionMeta>
  365. */
  366. public function getMeta()
  367. {
  368. return $this->meta;
  369. }
  370. /**
  371. * Add media.
  372. *
  373. * @return Collection
  374. */
  375. public function addMedia(MediaInterface $media)
  376. {
  377. $this->media[] = $media;
  378. return $this;
  379. }
  380. /**
  381. * Remove media.
  382. *
  383. * @return void
  384. */
  385. public function removeMedia(MediaInterface $media)
  386. {
  387. $this->media->removeElement($media);
  388. }
  389. /**
  390. * Get media.
  391. *
  392. * @return DoctrineCollection<int, MediaInterface>
  393. */
  394. public function getMedia()
  395. {
  396. return $this->media;
  397. }
  398. /**
  399. * Add children.
  400. *
  401. * @return Collection
  402. */
  403. public function addChildren(CollectionInterface $children)
  404. {
  405. $this->children[] = $children;
  406. return $this;
  407. }
  408. /**
  409. * Remove children.
  410. *
  411. * @return void
  412. */
  413. public function removeChildren(CollectionInterface $children)
  414. {
  415. $this->children->removeElement($children);
  416. }
  417. /**
  418. * Set defaultMeta.
  419. *
  420. * @return Collection
  421. */
  422. public function setDefaultMeta(?CollectionMeta $defaultMeta = null)
  423. {
  424. $this->defaultMeta = $defaultMeta;
  425. return $this;
  426. }
  427. /**
  428. * Get defaultMeta.
  429. *
  430. * @return CollectionMeta
  431. */
  432. public function getDefaultMeta()
  433. {
  434. return $this->defaultMeta;
  435. }
  436. public function getSecurityContext()
  437. {
  438. return 'sulu.media.collections';
  439. }
  440. }