<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\AdminUi\UniversalDiscovery\Event\Subscriber;
use Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class RichTextAllowedLanguages implements EventSubscriberInterface
{
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
ConfigResolveEvent::NAME => ['onUdwConfigResolve'],
];
}
/**
* @param \Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent $event
*/
public function onUdwConfigResolve(ConfigResolveEvent $event): void
{
if (!in_array($event->getConfigName(), ['richtext_embed', 'richtext_embed_image'])) {
return;
}
$context = $event->getContext();
if (empty($context['languageCode'])) {
return;
}
$config = $event->getConfig();
$config['content_on_the_fly']['allowed_languages'] = [$context['languageCode']];
$event->setConfig($config);
}
}
class_alias(RichTextAllowedLanguages::class, 'EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\Subscriber\RichTextAllowedLanguages');