<?php
namespace App\Entity\Feed\Entry;
use App\Entity\Content\AbstractObject;
use App\Entity\Content\Events\Event\EventObject;
use App\Entity\Feed\AbstractEntry;
use App\Model\Content\Media\MediaCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(
* repositoryClass = "App\Doctrine\Repository\Feed\Entry\ContentEventEntryRepository",
* )
*/
class ContentEventEntry extends AbstractContentEntry
{
const DISCR = 'content.'.EventObject::DISCR;
/**
* {@inheritDoc}
* @return EventObject
*/
public function getObject(): ?AbstractObject
{
if ( ! $this->object instanceof EventObject) {
throw new \LogicException();
}
return $this->object;
}
/**
* {@inheritDoc}
* @param EventObject $object
*/
public function setObject(?AbstractObject $object): self
{
if ($object && ! $object instanceof EventObject) {
throw new \LogicException();
}
$this->object = $object;
return $this;
}
/**
* {@inheritDoc}
* @param EventObject $entity
*/
public function populate($entity): self
{
if ( ! $entity instanceof EventObject) {
throw new \LogicException();
}
parent::populate($entity);
$this
->setLabel($entity->getHeadline())
// TODO: handle both html and non-html content
->setPreview($entity->getDetails())
->setMedia(new MediaCollection($entity->getMedia() ? [$entity->getMedia()] : []))
;
return $this;
}
/**
* {@inheritDoc}
*/
public function getType(): string
{
return AbstractEntry::TYPES__EVENT;
}
}