src/App/Entity/Feed/Entry/ContentPostEntry.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\Posts\Post\PostObject;
  5. use App\Entity\Feed\AbstractEntry;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(
  9.  *     repositoryClass = "App\Doctrine\Repository\Feed\Entry\ContentPostEntryRepository",
  10.  * )
  11.  */
  12. class ContentPostEntry extends AbstractContentEntry
  13. {
  14.     const DISCR 'content.'.PostObject::DISCR;
  15.     /**
  16.      * {@inheritDoc}
  17.      * @return PostObject
  18.      */
  19.     public function getObject(): ?AbstractObject
  20.     {
  21.         if ( ! $this->object instanceof PostObject) {
  22.             throw new \LogicException();
  23.         }
  24.         return $this->object;
  25.     }
  26.     /**
  27.      * {@inheritDoc}
  28.      * @param PostObject $object
  29.      */
  30.     public function setObject(?AbstractObject $object): self
  31.     {
  32.         if ($object && ! $object instanceof PostObject) {
  33.             throw new \LogicException();
  34.         }
  35.         $this->object $object;
  36.         return $this;
  37.     }
  38.     /**
  39.      * {@inheritDoc}
  40.      * @param PostObject $entity
  41.      */
  42.     public function populate($entity): self
  43.     {
  44.         if ( ! $entity instanceof PostObject) {
  45.             throw new \LogicException();
  46.         }
  47.         parent::populate($entity);
  48.         $this
  49.             ->setLabel($entity->getHeadline())
  50.             ->setMedia($entity->getMedia())
  51.             ->setPreview($entity->getHtml() ?: $entity->getDetails() ?: null)
  52.             ->setLink($entity->getLink())
  53.         ;
  54.         return $this;
  55.     }
  56.     /**
  57.      * {@inheritDoc}
  58.      */
  59.     public function getType(): string
  60.     {
  61.         return AbstractEntry::TYPES__POST;
  62.     }
  63. }