src/App/Entity/Content/AbstractDraft.php line 44

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Content;
  3. use App\Entity\Content\Common\DiscriminatorInterface;
  4. use App\Entity\Content\Common\DiscriminatorTrait;
  5. use App\Entity\Content\Common\Props\HeadlineTrait;
  6. use App\Entity\Content\Common\Props\TimestampTrait;
  7. use App\Entity\Shared\UlidIdentifiableInterface;
  8. use App\Entity\Shared\UlidIdentifiableTrait;
  9. use App\Model\Content\ContentInterface;
  10. use App\Model\Content\DraftInterface;
  11. use App\Model\Content\ObjectInterface;
  12. use Cms\CoreBundle\Model\Interfaces\Blameable;
  13. use Cms\CoreBundle\Model\Interfaces\Timestampable;
  14. use Cms\TenantBundle\Model as Tenantable;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Doctrine\ORM\Mapping as ORM;
  18. /**
  19.  * @ORM\Entity(
  20.  *     repositoryClass = "App\Doctrine\Repository\Content\DraftRepository",
  21.  * )
  22.  * @ORM\InheritanceType("SINGLE_TABLE")
  23.  * @ORM\DiscriminatorColumn(
  24.  *     name = DiscriminatorInterface::COLUMN__NAME,
  25.  *     type = DiscriminatorInterface::COLUMN__TYPE,
  26.  *     length = 64,
  27.  * )
  28.  * @ORM\DiscriminatorMap(AbstractDraft::DISCRS)
  29.  * @ORM\Table(
  30.  *     name = "sn__content__draft",
  31.  *     indexes = {
  32.  *         @ORM\Index(
  33.  *             name = "idx__discr",
  34.  *             columns = {
  35.  *                 "discr",
  36.  *             },
  37.  *         ),
  38.  *     },
  39.  * )
  40.  */
  41. abstract class AbstractDraft
  42.     implements
  43.         Tenantable\TenantableInterface,
  44.         UlidIdentifiableInterface,
  45.         Timestampable\TimestampableInterface,
  46.         Blameable\BlameableInterface,
  47.         DiscriminatorInterface,
  48.         DraftInterface
  49. {
  50.     const DISCR null;
  51.     const DISCRS = [
  52.         Alerts\Alert\AlertDraft::DISCR => Alerts\Alert\AlertDraft::class,
  53.         Events\Event\EventDraft::DISCR => Events\Event\EventDraft::class,
  54.         Exhibits\Gallery\GalleryDraft::DISCR => Exhibits\Gallery\GalleryDraft::class,
  55.         Exhibits\Video\VideoDraft::DISCR => Exhibits\Video\VideoDraft::class,
  56.         Posts\Post\PostDraft::DISCR => Posts\Post\PostDraft::class,
  57.     ];
  58.     const CLASSES__OBJECT null;
  59.     const CLASSES__REVISION null;
  60.     use Tenantable\TenantableTrait;
  61.     use UlidIdentifiableTrait;
  62.     use Timestampable\TimestampableTrait;
  63.     use Blameable\BlameableTrait;
  64.     use DiscriminatorTrait;
  65.     use HeadlineTrait;
  66.     use TimestampTrait;
  67.     /**
  68.      * @var AbstractObject|null
  69.      */
  70.     protected ?AbstractObject $object null;
  71.     /**
  72.      * @var Collection|null
  73.      */
  74.     protected ?Collection $revisions null;
  75.     /**
  76.      * @param ContentInterface|null $content
  77.      */
  78.     public function __construct(?ContentInterface $content null)
  79.     {
  80.         $this->revisions = new ArrayCollection();
  81.         if ($content) {
  82.             $this->copy($content);
  83.         }
  84.     }
  85.     /**
  86.      * {@inheritDoc}
  87.      */
  88.     public static function getObjectClass(): string
  89.     {
  90.         return static::CLASSES__OBJECT;
  91.     }
  92.     /**
  93.      * {@inheritDoc}
  94.      */
  95.     public static function getRevisionClass(): ?string
  96.     {
  97.         return static::CLASSES__REVISION;
  98.     }
  99.     /**
  100.      * {@inheritDoc}
  101.      * @return AbstractObject
  102.      */
  103.     public function getObject(): ?ObjectInterface
  104.     {
  105.         return $this->object;
  106.     }
  107.     /**
  108.      * {@inheritDoc}
  109.      * @param AbstractObject $object
  110.      * @return $this
  111.      */
  112.     public function setObject(?ObjectInterface $object): self
  113.     {
  114.         $this->object $object;
  115.         return $this;
  116.     }
  117.     /**
  118.      * {@inheritDoc}
  119.      * @return Collection|AbstractRevision[]
  120.      */
  121.     public function getRevisions(): iterable
  122.     {
  123.         return $this->revisions;
  124.     }
  125. }