src/App/Entity/Feed/Entry/ContentGalleryEntry.php line 15

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