vendor/sulu/sulu/src/Sulu/Bundle/PageBundle/Document/BasePageDocument.php line 275

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\PageBundle\Document;
  11. use Sulu\Component\Content\Document\Behavior\ExtensionBehavior;
  12. use Sulu\Component\Content\Document\Behavior\LocalizedAuditableBehavior;
  13. use Sulu\Component\Content\Document\Behavior\LocalizedAuthorBehavior;
  14. use Sulu\Component\Content\Document\Behavior\LocalizedLastModifiedBehavior;
  15. use Sulu\Component\Content\Document\Behavior\LocalizedStructureBehavior;
  16. use Sulu\Component\Content\Document\Behavior\NavigationContextBehavior;
  17. use Sulu\Component\Content\Document\Behavior\OrderBehavior;
  18. use Sulu\Component\Content\Document\Behavior\RedirectTypeBehavior;
  19. use Sulu\Component\Content\Document\Behavior\ResourceSegmentBehavior;
  20. use Sulu\Component\Content\Document\Behavior\SecurityBehavior;
  21. use Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior;
  22. use Sulu\Component\Content\Document\Behavior\WebspaceBehavior;
  23. use Sulu\Component\Content\Document\Behavior\WorkflowStageBehavior;
  24. use Sulu\Component\Content\Document\Extension\ExtensionContainer;
  25. use Sulu\Component\Content\Document\RedirectType;
  26. use Sulu\Component\Content\Document\Structure\Structure;
  27. use Sulu\Component\Content\Document\Structure\StructureInterface;
  28. use Sulu\Component\Content\Document\WorkflowStage;
  29. use Sulu\Component\DocumentManager\Behavior\Mapping\ChildrenBehavior;
  30. use Sulu\Component\DocumentManager\Behavior\Mapping\LocalizedTitleBehavior;
  31. use Sulu\Component\DocumentManager\Behavior\Mapping\NodeNameBehavior;
  32. use Sulu\Component\DocumentManager\Behavior\Mapping\PathBehavior;
  33. use Sulu\Component\DocumentManager\Behavior\Mapping\UuidBehavior;
  34. use Sulu\Component\DocumentManager\Behavior\VersionBehavior;
  35. use Sulu\Component\DocumentManager\Collection\ChildrenCollection;
  36. use Sulu\Component\DocumentManager\Version;
  37. /**
  38. * Base document for Page-like documents (i.e. Page and Home documents).
  39. */
  40. class BasePageDocument implements
  41. NodeNameBehavior,
  42. LocalizedStructureBehavior,
  43. ResourceSegmentBehavior,
  44. NavigationContextBehavior,
  45. RedirectTypeBehavior,
  46. WorkflowStageBehavior,
  47. ShadowLocaleBehavior,
  48. UuidBehavior,
  49. ChildrenBehavior,
  50. PathBehavior,
  51. ExtensionBehavior,
  52. OrderBehavior,
  53. WebspaceBehavior,
  54. SecurityBehavior,
  55. LocalizedAuditableBehavior,
  56. LocalizedTitleBehavior,
  57. VersionBehavior,
  58. LocalizedAuthorBehavior,
  59. LocalizedLastModifiedBehavior
  60. {
  61. public const RESOURCE_KEY = 'pages';
  62. /**
  63. * The name of this node.
  64. *
  65. * @var string
  66. */
  67. protected $nodeName;
  68. /**
  69. * Datetime of create document.
  70. *
  71. * @var \DateTime
  72. */
  73. protected $created;
  74. /**
  75. * Changed date of page.
  76. *
  77. * @var \DateTime
  78. */
  79. protected $changed;
  80. /**
  81. * User ID of creator.
  82. *
  83. * @var int|null
  84. */
  85. protected $creator;
  86. /**
  87. * User ID of changer.
  88. *
  89. * @var int|null
  90. */
  91. protected $changer;
  92. /**
  93. * Title of document.
  94. *
  95. * @var string
  96. */
  97. protected $title;
  98. /**
  99. * Segment.
  100. *
  101. * @var string
  102. */
  103. protected $resourceSegment;
  104. /**
  105. * @var string[]
  106. */
  107. protected $navigationContexts = [];
  108. /**
  109. * Type of redirection.
  110. *
  111. * @var int
  112. */
  113. protected $redirectType;
  114. /**
  115. * The target of redirection.
  116. *
  117. * @var object|null
  118. */
  119. protected $redirectTarget;
  120. /**
  121. * The External redirect.
  122. *
  123. * @var string|null
  124. */
  125. protected $redirectExternal;
  126. /**
  127. * Workflow Stage currently Test or Published.
  128. *
  129. * @var int
  130. */
  131. protected $workflowStage;
  132. /**
  133. * Is Document is published.
  134. *
  135. * @var bool
  136. */
  137. protected $published;
  138. /**
  139. * Shadow locale is enabled.
  140. *
  141. * @var bool
  142. */
  143. protected $shadowLocaleEnabled = false;
  144. /**
  145. * Shadow locale.
  146. *
  147. * @var string|null
  148. */
  149. protected $shadowLocale;
  150. /**
  151. * Universal Identifier.
  152. *
  153. * @var string
  154. */
  155. protected $uuid;
  156. /**
  157. * Document's type of structure ie default, complex...
  158. *
  159. * @var string|null
  160. */
  161. protected $structureType;
  162. /**
  163. * Structure.
  164. *
  165. * @var StructureInterface
  166. */
  167. protected $structure;
  168. /**
  169. * Document's locale.
  170. *
  171. * @var string
  172. */
  173. protected $locale;
  174. /**
  175. * Document's original locale.
  176. *
  177. * @var string
  178. */
  179. protected $originalLocale;
  180. /**
  181. * Document's children.
  182. *
  183. * @var ChildrenCollection
  184. */
  185. protected $children;
  186. /**
  187. * Path of Document.
  188. *
  189. * @var string
  190. */
  191. protected $path;
  192. /**
  193. * Document's extensions ie seo, ...
  194. *
  195. * @var array<mixed[]>|ExtensionContainer
  196. */
  197. protected $extensions;
  198. /**
  199. * Document's webspace name.
  200. *
  201. * @var string
  202. */
  203. protected $webspaceName;
  204. /**
  205. * Document's order.
  206. *
  207. * @var int
  208. */
  209. protected $suluOrder;
  210. /**
  211. * List of permissions.
  212. *
  213. * @var array
  214. */
  215. protected $permissions = [];
  216. /**
  217. * List of versions.
  218. *
  219. * @var Version[]
  220. */
  221. protected $versions = [];
  222. /**
  223. * Date of lastModified.
  224. *
  225. * @var \DateTime|null
  226. */
  227. protected $lastModified;
  228. /**
  229. * Date of authoring.
  230. *
  231. * @var \DateTime
  232. */
  233. protected $authored;
  234. /**
  235. * Id of author.
  236. *
  237. * @var int|null
  238. */
  239. protected $author;
  240. public function __construct()
  241. {
  242. $this->workflowStage = WorkflowStage::TEST;
  243. $this->redirectType = RedirectType::NONE;
  244. $this->structure = new Structure();
  245. $this->extensions = new ExtensionContainer();
  246. $this->children = new \ArrayIterator();
  247. }
  248. public function getNodeName()
  249. {
  250. return $this->nodeName;
  251. }
  252. public function getTitle()
  253. {
  254. return $this->title;
  255. }
  256. public function setTitle($title)
  257. {
  258. $this->title = $title;
  259. }
  260. public function getCreated()
  261. {
  262. return $this->created;
  263. }
  264. /**
  265. * @param \DateTime $created
  266. *
  267. * @return void
  268. */
  269. public function setCreated($created)
  270. {
  271. $this->created = $created;
  272. }
  273. public function getChanged()
  274. {
  275. return $this->changed;
  276. }
  277. public function getCreator()
  278. {
  279. return $this->creator;
  280. }
  281. /**
  282. * @param int|null $userId
  283. *
  284. * @return void
  285. */
  286. public function setCreator($userId)
  287. {
  288. $this->creator = $userId;
  289. }
  290. public function getChanger()
  291. {
  292. return $this->changer;
  293. }
  294. public function getResourceSegment()
  295. {
  296. return $this->resourceSegment;
  297. }
  298. public function setResourceSegment($resourceSegment)
  299. {
  300. $this->resourceSegment = $resourceSegment;
  301. }
  302. public function getNavigationContexts()
  303. {
  304. return $this->navigationContexts;
  305. }
  306. public function setNavigationContexts(array $navigationContexts = [])
  307. {
  308. $this->navigationContexts = $navigationContexts;
  309. }
  310. public function getRedirectType()
  311. {
  312. return $this->redirectType;
  313. }
  314. public function setRedirectType($redirectType)
  315. {
  316. $this->redirectType = $redirectType;
  317. }
  318. public function getRedirectTarget()
  319. {
  320. return $this->redirectTarget;
  321. }
  322. public function setRedirectTarget($redirectTarget)
  323. {
  324. $this->redirectTarget = $redirectTarget;
  325. }
  326. public function getRedirectExternal()
  327. {
  328. return $this->redirectExternal;
  329. }
  330. public function setRedirectExternal($redirectExternal)
  331. {
  332. $this->redirectExternal = $redirectExternal;
  333. }
  334. public function getWorkflowStage()
  335. {
  336. return $this->workflowStage;
  337. }
  338. public function setWorkflowStage($workflowStage)
  339. {
  340. $this->workflowStage = $workflowStage;
  341. }
  342. public function getPublished()
  343. {
  344. return $this->published;
  345. }
  346. public function getShadowLocale()
  347. {
  348. return $this->shadowLocale;
  349. }
  350. public function setShadowLocale($shadowLocale)
  351. {
  352. $this->shadowLocale = $shadowLocale;
  353. }
  354. public function isShadowLocaleEnabled()
  355. {
  356. return $this->shadowLocaleEnabled;
  357. }
  358. public function setShadowLocaleEnabled($shadowLocaleEnabled)
  359. {
  360. $this->shadowLocaleEnabled = $shadowLocaleEnabled;
  361. }
  362. public function getUuid()
  363. {
  364. return $this->uuid;
  365. }
  366. public function getStructureType()
  367. {
  368. return $this->structureType;
  369. }
  370. public function getStructure()
  371. {
  372. return $this->structure;
  373. }
  374. public function setStructureType($structureType)
  375. {
  376. $this->structureType = $structureType;
  377. }
  378. public function getLocale()
  379. {
  380. return $this->locale;
  381. }
  382. public function setLocale($locale)
  383. {
  384. $this->locale = $locale;
  385. }
  386. public function getOriginalLocale()
  387. {
  388. return $this->originalLocale;
  389. }
  390. public function setOriginalLocale($originalLocale)
  391. {
  392. $this->originalLocale = $originalLocale;
  393. }
  394. public function getChildren()
  395. {
  396. return $this->children;
  397. }
  398. public function getPath()
  399. {
  400. return $this->path;
  401. }
  402. public function getExtensionsData()
  403. {
  404. return $this->extensions;
  405. }
  406. public function setExtensionsData($extensions)
  407. {
  408. $this->extensions = $extensions;
  409. }
  410. public function setExtension($name, $data)
  411. {
  412. $this->extensions[$name] = $data;
  413. }
  414. public function getWebspaceName()
  415. {
  416. return $this->webspaceName;
  417. }
  418. public function getSuluOrder()
  419. {
  420. return $this->suluOrder;
  421. }
  422. public function setSuluOrder($order)
  423. {
  424. $this->suluOrder = $order;
  425. }
  426. public function setPermissions(array $permissions)
  427. {
  428. $this->permissions = $permissions;
  429. }
  430. public function getPermissions()
  431. {
  432. return $this->permissions;
  433. }
  434. public function getVersions()
  435. {
  436. return $this->versions;
  437. }
  438. public function setVersions($versions)
  439. {
  440. $this->versions = $versions;
  441. }
  442. public function getLastModifiedEnabled()
  443. {
  444. return null !== $this->lastModified;
  445. }
  446. /**
  447. * @return \DateTime|null
  448. */
  449. public function getLastModified()
  450. {
  451. return $this->lastModified;
  452. }
  453. /**
  454. * @param \DateTime|null $lastModified
  455. *
  456. * @return void
  457. */
  458. public function setLastModified($lastModified)
  459. {
  460. $this->lastModified = $lastModified;
  461. }
  462. public function getAuthored()
  463. {
  464. return $this->authored;
  465. }
  466. /**
  467. * @param \DateTime $authored
  468. *
  469. * @return void
  470. */
  471. public function setAuthored($authored)
  472. {
  473. $this->authored = $authored;
  474. }
  475. public function getAuthor()
  476. {
  477. return $this->author;
  478. }
  479. /**
  480. * @param int|null $contactId
  481. *
  482. * @return void
  483. */
  484. public function setAuthor($contactId)
  485. {
  486. $this->author = $contactId;
  487. }
  488. }