src/App/Entity/Feed/Entry/ContentVideoEntry.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\Exhibits\Video\VideoObject;
  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\ContentVideoEntryRepository",
  11.  * )
  12.  */
  13. class ContentVideoEntry extends AbstractContentEntry
  14. {
  15.     const DISCR 'content.'.VideoObject::DISCR;
  16.     /**
  17.      * {@inheritDoc}
  18.      * @return VideoObject
  19.      */
  20.     public function getObject(): ?AbstractObject
  21.     {
  22.         if ( ! $this->object instanceof VideoObject) {
  23.             throw new \LogicException();
  24.         }
  25.         return $this->object;
  26.     }
  27.     /**
  28.      * {@inheritDoc}
  29.      * @param VideoObject $object
  30.      */
  31.     public function setObject(?AbstractObject $object): self
  32.     {
  33.         if ($object && ! $object instanceof VideoObject) {
  34.             throw new \LogicException();
  35.         }
  36.         $this->object $object;
  37.         return $this;
  38.     }
  39.     /**
  40.      * {@inheritDoc}
  41.      * @param VideoObject $entity
  42.      */
  43.     public function populate($entity): self
  44.     {
  45.         if ( ! $entity instanceof VideoObject) {
  46.             throw new \LogicException();
  47.         }
  48.         parent::populate($entity);
  49.         $this
  50.             ->setLabel($entity->getHeadline())
  51.             ->setMedia(new MediaCollection([
  52.                 $entity->getMedia()
  53.             ]))
  54.         ;
  55.         return $this;
  56.     }
  57.     /**
  58.      * {@inheritDoc}
  59.      */
  60.     public function getType(): string
  61.     {
  62.         return AbstractEntry::TYPES__VIDEO;
  63.     }
  64. }