<?php
namespace App\EventListener\SonataAdmin\Block\VOD;
use App\Enum\Common\AdminCodesEnum;
use Sonata\BlockBundle\Event\BlockEvent;
use Sonata\BlockBundle\Model\Block;
/**
* Class TitleMediaIdsListener.
*/
class TitleMediaIdsListener
{
/**
* Responsible for rendering the media ids table for existing media formats.
*
* @param \Sonata\BlockBundle\Event\BlockEvent $event
* The instance of the dispatched event
*/
public function onFormTopDispatched(BlockEvent $event): void
{
if (!($admin = $event->getSetting('admin'))) {
return;
}
if (AdminCodesEnum::VOD_TITLE_MEDIA_FORMAT !== $admin->getCode()) {
return;
}
$block = new Block();
$block->setId(uniqid('', true));
$block->setSettings($event->getSettings());
$block->setType('app.block.vod.media_ids_table');
$block->setSetting('entity', $admin->getSubject());
$event->addBlock($block);
}
}