<?php
namespace Cms\ModuleBundle\Entity;
use Cms\CoreBundle\Model\Interfaces\Lockable\LockableInterface;
use Cms\CoreBundle\Model\Interfaces\Lockable\LockableTrait;
use Cms\WorkflowsBundle\Model\Interfaces\Draftable\DraftableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Draft
* @package Cms\ModuleBundle\Entity
*
* @ORM\MappedSuperclass
*/
abstract class Draft extends ModuleEntity implements LockableInterface, DraftableInterface
{
const STATUS__OPEN = 'open';
const STATUS__CLOSED = 'closed';
const STATUSES = array(
self::STATUS__OPEN,
self::STATUS__CLOSED,
);
use LockableTrait;
/**
* @var Proxy
*/
protected $proxy = null;
/**
* @var string
*
* @ORM\Column(type = "string", nullable = false)
*/
protected $status = null;
/**
* @var ArrayCollection|Revision[]
*/
protected $revisions;
/**
* @var Revision
*/
protected $revision = null;
/**
* Draft constructor.
*/
public function __construct()
{
parent::__construct();
$this->revisions = new ArrayCollection();
}
/**
* @return Proxy
*/
public function getProxy()
{
return $this->proxy;
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* @return ArrayCollection|Revision[]
*/
public function getRevisions()
{
return $this->revisions;
}
/**
* @return Revision
*/
public function getRevision()
{
return $this->revision;
}
/**
* @param Proxy $value
* @return $this
*/
public function setProxy(Proxy $value)
{
$this->proxy = $value;
return $this;
}
/**
* @param string $status
* @return $this
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* @param Revision|null $value
* @return $this
*/
public function setRevision(Revision $value = null)
{
$this->revision = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLockName()
{
$data = $this->getData();
switch (true) {
case $data->has('title'):
return $data->get('title');
case $data->has('name'):
return $data->get('name');
}
throw new \Exception();
}
}