<?php
namespace App\Entity\Feed\Entry;
use App\Entity\Content\AbstractObject;
use App\Entity\Content\Exhibits\Video\VideoObject;
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\ContentVideoEntryRepository",
* )
*/
class ContentVideoEntry extends AbstractContentEntry
{
const DISCR = 'content.'.VideoObject::DISCR;
/**
* {@inheritDoc}
* @return VideoObject
*/
public function getObject(): ?AbstractObject
{
if ( ! $this->object instanceof VideoObject) {
throw new \LogicException();
}
return $this->object;
}
/**
* {@inheritDoc}
* @param VideoObject $object
*/
public function setObject(?AbstractObject $object): self
{
if ($object && ! $object instanceof VideoObject) {
throw new \LogicException();
}
$this->object = $object;
return $this;
}
/**
* {@inheritDoc}
* @param VideoObject $entity
*/
public function populate($entity): self
{
if ( ! $entity instanceof VideoObject) {
throw new \LogicException();
}
parent::populate($entity);
$this
->setLabel($entity->getHeadline())
->setMedia(new MediaCollection([
$entity->getMedia()
]))
;
return $this;
}
/**
* {@inheritDoc}
*/
public function getType(): string
{
return AbstractEntry::TYPES__VIDEO;
}
}