src/Cms/ModuleBundle/Entity/Proxy.php line 20

Open in your IDE?
  1. <?php
  2. namespace Cms\ModuleBundle\Entity;
  3. use App\Entity\Content\Common\DiscriminatorInterface;
  4. use App\Entity\Content\Common\DiscriminatorTrait;
  5. use Cms\ContainerBundle\Entity\Container;
  6. use Cms\CoreBundle\Model\Interfaces\Lockable\LockableInterface;
  7. use Cms\CoreBundle\Model\Interfaces\Lockable\LockableTrait;
  8. use Cms\Modules\PageBundle\Entity\Page\PageProxy;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12.  * Class Proxy
  13.  * @package Cms\ModuleBundle\Entity
  14.  *
  15.  * @ORM\MappedSuperclass
  16.  */
  17. abstract class Proxy extends ModuleEntity implements LockableInterfaceDiscriminatorInterface
  18. {
  19.     const DISCR null;
  20.     const DISCRS = [
  21.         PageProxy::DISCR => PageProxy::class,
  22.     ];
  23.     const ROUTING_SLUG null;
  24.     use LockableTrait;
  25.     use DiscriminatorTrait;
  26.     /**
  27.      * @var Container
  28.      *
  29.      * @ORM\ManyToOne(targetEntity = "Cms\ContainerBundle\Entity\Container")
  30.      * @ORM\JoinColumn(name = "container", referencedColumnName = "id", onDelete = "CASCADE")
  31.      */
  32.     protected $container null;
  33.     /**
  34.      * @var ArrayCollection|History[]
  35.      */
  36.     protected $histories;
  37.     /**
  38.      * @var History
  39.      */
  40.     protected $history null;
  41.     /**
  42.      * @var ArrayCollection|Draft[]
  43.      */
  44.     protected $drafts;
  45.     /**
  46.      * @var Draft
  47.      */
  48.     protected $draft;
  49.     /**
  50.      * @var bool
  51.      *
  52.      * @ORM\Column(
  53.      *     type = "boolean",
  54.      *     nullable = false,
  55.      *     options = {
  56.      *         "default" = false
  57.      *     }
  58.      * )
  59.      */
  60.     protected $placeholder false;
  61.     /**
  62.      * Proxy constructor.
  63.      */
  64.     public function __construct()
  65.     {
  66.         parent::__construct();
  67.         $this->histories = new ArrayCollection();
  68.         $this->drafts = new ArrayCollection();
  69.     }
  70.     /**
  71.      * @return bool
  72.      */
  73.     public function isJumpable()
  74.     {
  75.         return ( ! $this->isPlaceholder());
  76.     }
  77.     /**
  78.      * @return Container
  79.      * @deprected
  80.      */
  81.     public function getContainer()
  82.     {
  83.         return $this->container;
  84.     }
  85.     /**
  86.      * @return Container|null
  87.      */
  88.     public function getDepartment(): ?Container
  89.     {
  90.         return $this->getContainer();
  91.     }
  92.     /**
  93.      * @return ArrayCollection|History[]
  94.      */
  95.     public function getHistories()
  96.     {
  97.         return $this->histories;
  98.     }
  99.     /**
  100.      * @return History
  101.      */
  102.     public function getHistory()
  103.     {
  104.         return $this->history;
  105.     }
  106.     /**
  107.      * @return ArrayCollection|Draft[]
  108.      */
  109.     public function getDrafts()
  110.     {
  111.         return $this->drafts;
  112.     }
  113.     /**
  114.      * @return Draft
  115.      */
  116.     public function getDraft()
  117.     {
  118.         return $this->draft;
  119.     }
  120.     /**
  121.      * @param Container $value
  122.      * @return $this
  123.      */
  124.     public function setContainer(Container $value)
  125.     {
  126.         $this->container $value;
  127.         return $this;
  128.     }
  129.     /**
  130.      * @param History|null $value
  131.      * @return $this
  132.      */
  133.     public function setHistory(History $value null)
  134.     {
  135.         $this->history $value;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @param Draft|null $value
  140.      * @return $this
  141.      */
  142.     public function setDraft(Draft $value null)
  143.     {
  144.         $this->draft $value;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return bool
  149.      */
  150.     public function isPlaceholder()
  151.     {
  152.         return ($this->placeholder === true);
  153.     }
  154.     /**
  155.      * @param bool $value
  156.      * @return $this
  157.      */
  158.     public function setPlaceholder($value)
  159.     {
  160.         $this->placeholder = ($value === true);
  161.         return $this;
  162.     }
  163.     /**
  164.      * {@inheritdoc}
  165.      */
  166.     public function getLockName()
  167.     {
  168.         $data $this->getData();
  169.         switch (true) {
  170.             case $data->has('title'):
  171.                 return $data->get('title');
  172.             case $data->has('name'):
  173.                 return $data->get('name');
  174.         }
  175.         throw new \Exception();
  176.     }
  177. }