src/App/Entity/Feed/Entry/ContentEventEntry.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Feed\Entry;
  3. use App\Entity\Content\AbstractObject;
  4. use App\Entity\Content\Events\Event\EventObject;
  5. use App\Entity\Feed\AbstractEntry;
  6. use App\Model\Content\Media\MediaCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(
  10.  *     repositoryClass = "App\Doctrine\Repository\Feed\Entry\ContentEventEntryRepository",
  11.  * )
  12.  */
  13. class ContentEventEntry extends AbstractContentEntry
  14. {
  15.     const DISCR 'content.'.EventObject::DISCR;
  16.     /**
  17.      * {@inheritDoc}
  18.      * @return EventObject
  19.      */
  20.     public function getObject(): ?AbstractObject
  21.     {
  22.         if ( ! $this->object instanceof EventObject) {
  23.             throw new \LogicException();
  24.         }
  25.         return $this->object;
  26.     }
  27.     /**
  28.      * {@inheritDoc}
  29.      * @param EventObject $object
  30.      */
  31.     public function setObject(?AbstractObject $object): self
  32.     {
  33.         if ($object && ! $object instanceof EventObject) {
  34.             throw new \LogicException();
  35.         }
  36.         $this->object $object;
  37.         return $this;
  38.     }
  39.     /**
  40.      * {@inheritDoc}
  41.      * @param EventObject $entity
  42.      */
  43.     public function populate($entity): self
  44.     {
  45.         if ( ! $entity instanceof EventObject) {
  46.             throw new \LogicException();
  47.         }
  48.         parent::populate($entity);
  49.         $this
  50.             ->setLabel($entity->getHeadline())
  51.             // TODO: handle both html and non-html content
  52.             ->setPreview($entity->getDetails())
  53.             ->setMedia(new MediaCollection($entity->getMedia() ? [$entity->getMedia()] : []))
  54.         ;
  55.         return $this;
  56.     }
  57.     /**
  58.      * {@inheritDoc}
  59.      */
  60.     public function getType(): string
  61.     {
  62.         return AbstractEntry::TYPES__EVENT;
  63.     }
  64. }