vendor/sulu/article-bundle/Document/ArticleDocument.php line 42

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\ArticleBundle\Document;
  11. use Sulu\Bundle\ArticleBundle\Document\Behavior\DateShardingBehavior;
  12. use Sulu\Bundle\ArticleBundle\Document\Behavior\RoutableBehavior;
  13. use Sulu\Bundle\ArticleBundle\Document\Behavior\RoutablePageBehavior;
  14. use Sulu\Bundle\ArticleBundle\Document\Behavior\WebspaceBehavior;
  15. use Sulu\Bundle\RouteBundle\Model\RouteInterface;
  16. use Sulu\Component\Content\Document\Behavior\ExtensionBehavior;
  17. use Sulu\Component\Content\Document\Behavior\LocalizedAuditableBehavior;
  18. use Sulu\Component\Content\Document\Behavior\LocalizedAuthorBehavior;
  19. use Sulu\Component\Content\Document\Behavior\LocalizedStructureBehavior;
  20. use Sulu\Component\Content\Document\Behavior\ShadowLocaleBehavior;
  21. use Sulu\Component\Content\Document\Behavior\StructureBehavior;
  22. use Sulu\Component\Content\Document\Behavior\WorkflowStageBehavior;
  23. use Sulu\Component\Content\Document\Extension\ExtensionContainer;
  24. use Sulu\Component\Content\Document\Structure\Structure;
  25. use Sulu\Component\Content\Document\Structure\StructureInterface;
  26. use Sulu\Component\DocumentManager\Behavior\Mapping\ChildrenBehavior;
  27. use Sulu\Component\DocumentManager\Behavior\Mapping\LocalizedTitleBehavior;
  28. use Sulu\Component\DocumentManager\Behavior\Mapping\NodeNameBehavior;
  29. use Sulu\Component\DocumentManager\Behavior\Mapping\PathBehavior;
  30. use Sulu\Component\DocumentManager\Behavior\Mapping\UuidBehavior;
  31. use Sulu\Component\DocumentManager\Behavior\Path\AutoNameBehavior;
  32. use Sulu\Component\DocumentManager\Behavior\VersionBehavior;
  33. use Sulu\Component\DocumentManager\Collection\ChildrenCollection;
  34. use Sulu\Component\DocumentManager\Version;
  35. /**
  36.  * Represents an article in phpcr.
  37.  */
  38. class ArticleDocument implements UuidBehavior,
  39.     NodeNameBehavior,
  40.     AutoNameBehavior,
  41.     PathBehavior,
  42.     LocalizedTitleBehavior,
  43.     StructureBehavior,
  44.     LocalizedStructureBehavior,
  45.     LocalizedAuditableBehavior,
  46.     DateShardingBehavior,
  47.     RoutableBehavior,
  48.     ExtensionBehavior,
  49.     WorkflowStageBehavior,
  50.     VersionBehavior,
  51.     LocalizedAuthorBehavior,
  52.     ChildrenBehavior,
  53.     ArticleInterface,
  54.     ShadowLocaleBehavior,
  55.     WebspaceBehavior
  56. {
  57.     public const RESOURCE_KEY 'articles';
  58.     public const LIST_KEY 'articles';
  59.     /**
  60.      * @var string
  61.      */
  62.     protected $uuid;
  63.     /**
  64.      * @var string
  65.      */
  66.     protected $nodeName;
  67.     /**
  68.      * @var string
  69.      */
  70.     protected $path;
  71.     /**
  72.      * @var object
  73.      */
  74.     protected $parent;
  75.     /**
  76.      * @var string
  77.      */
  78.     protected $title;
  79.     /**
  80.      * @var string
  81.      */
  82.     protected $pageTitle;
  83.     /**
  84.      * @var array
  85.      */
  86.     protected $pages;
  87.     /**
  88.      * @var RouteInterface
  89.      */
  90.     protected $route;
  91.     /**
  92.      * @var string
  93.      */
  94.     protected $routePath;
  95.     /**
  96.      * @var string
  97.      */
  98.     protected $locale;
  99.     /**
  100.      * @var string
  101.      */
  102.     protected $originalLocale;
  103.     /**
  104.      * @var string
  105.      */
  106.     protected $structureType;
  107.     /**
  108.      * @var StructureInterface
  109.      */
  110.     protected $structure;
  111.     /**
  112.      * @var int
  113.      */
  114.     protected $creator;
  115.     /**
  116.      * @var int
  117.      */
  118.     protected $changer;
  119.     /**
  120.      * @var \DateTime
  121.      */
  122.     protected $created;
  123.     /**
  124.      * @var \DateTime
  125.      */
  126.     protected $changed;
  127.     /**
  128.      * @var int
  129.      */
  130.     protected $author;
  131.     /**
  132.      * @var \DateTime
  133.      */
  134.     protected $authored;
  135.     /**
  136.      * Document's extensions ie seo, ...
  137.      *
  138.      * @var ExtensionContainer
  139.      */
  140.     protected $extensions;
  141.     /**
  142.      * Workflow Stage currently Test or Published.
  143.      *
  144.      * @var int
  145.      */
  146.     protected $workflowStage;
  147.     /**
  148.      * Is Document is published.
  149.      *
  150.      * @var bool
  151.      */
  152.     protected $published;
  153.     /**
  154.      * List of versions.
  155.      *
  156.      * @var Version[]
  157.      */
  158.     protected $versions = [];
  159.     /**
  160.      * @var ChildrenCollection
  161.      */
  162.     protected $children;
  163.     /**
  164.      * Shadow locale is enabled.
  165.      *
  166.      * @var bool
  167.      */
  168.     protected $shadowLocaleEnabled false;
  169.     /**
  170.      * Shadow locale.
  171.      *
  172.      * @var string
  173.      */
  174.     protected $shadowLocale;
  175.     /**
  176.      * Main webspace.
  177.      *
  178.      * @var null|string
  179.      */
  180.     protected $mainWebspace;
  181.     /**
  182.      * Additional webspaces.
  183.      *
  184.      * @var null|string[]
  185.      */
  186.     protected $additionalWebspaces;
  187.     public function __construct()
  188.     {
  189.         $this->structure = new Structure();
  190.         $this->extensions = new ExtensionContainer();
  191.         $this->children = new \ArrayIterator();
  192.     }
  193.     public function getUuid()
  194.     {
  195.         return $this->uuid;
  196.     }
  197.     public function setUuid($uuid): RoutablePageBehavior
  198.     {
  199.         $this->uuid $uuid;
  200.         return $this;
  201.     }
  202.     public function getNodeName()
  203.     {
  204.         return $this->nodeName;
  205.     }
  206.     public function getPath()
  207.     {
  208.         return $this->path;
  209.     }
  210.     public function getParent()
  211.     {
  212.         return $this->parent;
  213.     }
  214.     public function setParent($document)
  215.     {
  216.         $this->parent $document;
  217.     }
  218.     public function getTitle()
  219.     {
  220.         return $this->title;
  221.     }
  222.     public function setTitle($title)
  223.     {
  224.         $this->title $title;
  225.     }
  226.     /**
  227.      * Returns route.
  228.      *
  229.      * @return RouteInterface
  230.      */
  231.     public function getRoute()
  232.     {
  233.         return $this->route;
  234.     }
  235.     public function setRoute(RouteInterface $route)
  236.     {
  237.         $this->route $route;
  238.     }
  239.     public function removeRoute(): RoutablePageBehavior
  240.     {
  241.         $this->route null;
  242.         $this->routePath null;
  243.         return $this;
  244.     }
  245.     public function getRoutePath(): ?string
  246.     {
  247.         return $this->routePath;
  248.     }
  249.     public function setRoutePath($routePath): RoutablePageBehavior
  250.     {
  251.         $this->routePath $routePath;
  252.         return $this;
  253.     }
  254.     public function getClass(): string
  255.     {
  256.         return \get_class($this);
  257.     }
  258.     public function getLocale()
  259.     {
  260.         return $this->locale;
  261.     }
  262.     public function setLocale($locale)
  263.     {
  264.         $this->locale $locale;
  265.     }
  266.     public function getOriginalLocale()
  267.     {
  268.         return $this->originalLocale;
  269.     }
  270.     public function setOriginalLocale($locale)
  271.     {
  272.         $this->originalLocale $locale;
  273.     }
  274.     public function getStructureType(): ?string
  275.     {
  276.         return $this->structureType;
  277.     }
  278.     public function setStructureType($structureType)
  279.     {
  280.         $this->structureType $structureType;
  281.     }
  282.     public function getStructure(): StructureInterface
  283.     {
  284.         return $this->structure;
  285.     }
  286.     public function getCreator()
  287.     {
  288.         return $this->creator;
  289.     }
  290.     /**
  291.      * @param int|null $userId
  292.      *
  293.      * @return void
  294.      */
  295.     public function setCreator($userId)
  296.     {
  297.         $this->creator $userId;
  298.     }
  299.     public function getChanger()
  300.     {
  301.         return $this->changer;
  302.     }
  303.     public function getCreated()
  304.     {
  305.         return $this->created;
  306.     }
  307.     /**
  308.      * @param \DateTime $created
  309.      *
  310.      * @return void
  311.      */
  312.     public function setCreated($created)
  313.     {
  314.         $this->created $created;
  315.     }
  316.     public function getChanged()
  317.     {
  318.         return $this->changed;
  319.     }
  320.     /**
  321.      * Returns identifier.
  322.      *
  323.      * @return mixed
  324.      */
  325.     public function getId()
  326.     {
  327.         return $this->getUuid();
  328.     }
  329.     public function getExtensionsData()
  330.     {
  331.         return $this->extensions;
  332.     }
  333.     public function setExtensionsData($extensions)
  334.     {
  335.         $this->extensions $extensions;
  336.     }
  337.     public function setExtension($name$data)
  338.     {
  339.         $this->extensions[$name] = $data;
  340.     }
  341.     public function getWorkflowStage()
  342.     {
  343.         return $this->workflowStage;
  344.     }
  345.     public function setWorkflowStage($workflowStage)
  346.     {
  347.         $this->workflowStage $workflowStage;
  348.     }
  349.     public function getPublished()
  350.     {
  351.         return $this->published;
  352.     }
  353.     public function getAuthored()
  354.     {
  355.         return $this->authored;
  356.     }
  357.     public function setAuthored($authored)
  358.     {
  359.         $this->authored $authored;
  360.     }
  361.     public function getAuthor()
  362.     {
  363.         return $this->author;
  364.     }
  365.     public function setAuthor($author)
  366.     {
  367.         $this->author $author;
  368.     }
  369.     public function getVersions()
  370.     {
  371.         return $this->versions;
  372.     }
  373.     public function setVersions($versions)
  374.     {
  375.         $this->versions $versions;
  376.     }
  377.     public function getChildren()
  378.     {
  379.         return $this->children;
  380.     }
  381.     public function getArticleUuid(): string
  382.     {
  383.         return $this->getUuid();
  384.     }
  385.     public function getPageUuid(): string
  386.     {
  387.         return $this->getUuid();
  388.     }
  389.     public function getPageNumber(): int
  390.     {
  391.         return 1;
  392.     }
  393.     public function getPageTitle(): ?string
  394.     {
  395.         return $this->pageTitle;
  396.     }
  397.     /**
  398.      * Set pageTitle.
  399.      *
  400.      * @param string $pageTitle
  401.      *
  402.      * @return $this
  403.      */
  404.     public function setPageTitle($pageTitle)
  405.     {
  406.         $this->pageTitle $pageTitle;
  407.         return $this;
  408.     }
  409.     /**
  410.      * Returns pages.
  411.      *
  412.      * @return array
  413.      */
  414.     public function getPages()
  415.     {
  416.         return $this->pages;
  417.     }
  418.     /**
  419.      * Set pages.
  420.      *
  421.      * @param array $pages
  422.      *
  423.      * @return $this
  424.      */
  425.     public function setPages($pages)
  426.     {
  427.         $this->pages $pages;
  428.         return $this;
  429.     }
  430.     public function getShadowLocale()
  431.     {
  432.         return $this->shadowLocale;
  433.     }
  434.     public function setShadowLocale($shadowLocale)
  435.     {
  436.         $this->shadowLocale $shadowLocale;
  437.     }
  438.     public function isShadowLocaleEnabled()
  439.     {
  440.         return $this->shadowLocaleEnabled;
  441.     }
  442.     public function setShadowLocaleEnabled($shadowLocaleEnabled)
  443.     {
  444.         $this->shadowLocaleEnabled $shadowLocaleEnabled;
  445.     }
  446.     public function getMainWebspace(): ?string
  447.     {
  448.         return $this->mainWebspace;
  449.     }
  450.     public function setMainWebspace(?string $mainWebspace): WebspaceBehavior
  451.     {
  452.         $this->mainWebspace $mainWebspace;
  453.         return $this;
  454.     }
  455.     public function getAdditionalWebspaces(): ?array
  456.     {
  457.         return $this->additionalWebspaces;
  458.     }
  459.     public function setAdditionalWebspaces(?array $additionalWebspaces): WebspaceBehavior
  460.     {
  461.         $this->additionalWebspaces $additionalWebspaces;
  462.         return $this;
  463.     }
  464. }