src/Cms/ModuleBundle/Entity/Draft.php line 17

Open in your IDE?
  1. <?php
  2. namespace Cms\ModuleBundle\Entity;
  3. use Cms\CoreBundle\Model\Interfaces\Lockable\LockableInterface;
  4. use Cms\CoreBundle\Model\Interfaces\Lockable\LockableTrait;
  5. use Cms\WorkflowsBundle\Model\Interfaces\Draftable\DraftableInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Class Draft
  10.  * @package Cms\ModuleBundle\Entity
  11.  *
  12.  * @ORM\MappedSuperclass
  13.  */
  14. abstract class Draft extends ModuleEntity implements LockableInterfaceDraftableInterface
  15. {
  16.     const STATUS__OPEN 'open';
  17.     const STATUS__CLOSED 'closed';
  18.     const STATUSES = array(
  19.         self::STATUS__OPEN,
  20.         self::STATUS__CLOSED,
  21.     );
  22.     use LockableTrait;
  23.     /**
  24.      * @var Proxy
  25.      */
  26.     protected $proxy null;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(type = "string", nullable = false)
  31.      */
  32.     protected $status null;
  33.     /**
  34.      * @var ArrayCollection|Revision[]
  35.      */
  36.     protected $revisions;
  37.     /**
  38.      * @var Revision
  39.      */
  40.     protected $revision null;
  41.     /**
  42.      * Draft constructor.
  43.      */
  44.     public function __construct()
  45.     {
  46.         parent::__construct();
  47.         $this->revisions = new ArrayCollection();
  48.     }
  49.     /**
  50.      * @return Proxy
  51.      */
  52.     public function getProxy()
  53.     {
  54.         return $this->proxy;
  55.     }
  56.     /**
  57.      * @return string
  58.      */
  59.     public function getStatus()
  60.     {
  61.         return $this->status;
  62.     }
  63.     /**
  64.      * @return ArrayCollection|Revision[]
  65.      */
  66.     public function getRevisions()
  67.     {
  68.         return $this->revisions;
  69.     }
  70.     /**
  71.      * @return Revision
  72.      */
  73.     public function getRevision()
  74.     {
  75.         return $this->revision;
  76.     }
  77.     /**
  78.      * @param Proxy $value
  79.      * @return $this
  80.      */
  81.     public function setProxy(Proxy $value)
  82.     {
  83.         $this->proxy $value;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @param string $status
  88.      * @return $this
  89.      */
  90.     public function setStatus($status)
  91.     {
  92.         $this->status $status;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @param Revision|null $value
  97.      * @return $this
  98.      */
  99.     public function setRevision(Revision $value null)
  100.     {
  101.         $this->revision $value;
  102.         return $this;
  103.     }
  104.     /**
  105.      * {@inheritdoc}
  106.      */
  107.     public function getLockName()
  108.     {
  109.         $data $this->getData();
  110.         switch (true) {
  111.             case $data->has('title'):
  112.                 return $data->get('title');
  113.             case $data->has('name'):
  114.                 return $data->get('name');
  115.         }
  116.         throw new \Exception();
  117.     }
  118. }