vendor/ibexa/admin-ui/src/lib/UniversalDiscovery/Event/Subscriber/RichTextAllowedLanguages.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\AdminUi\UniversalDiscovery\Event\Subscriber;
  8. use Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. class RichTextAllowedLanguages implements EventSubscriberInterface
  11. {
  12. /**
  13. * @return array
  14. */
  15. public static function getSubscribedEvents(): array
  16. {
  17. return [
  18. ConfigResolveEvent::NAME => ['onUdwConfigResolve'],
  19. ];
  20. }
  21. /**
  22. * @param \Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent $event
  23. */
  24. public function onUdwConfigResolve(ConfigResolveEvent $event): void
  25. {
  26. if (!in_array($event->getConfigName(), ['richtext_embed', 'richtext_embed_image'])) {
  27. return;
  28. }
  29. $context = $event->getContext();
  30. if (empty($context['languageCode'])) {
  31. return;
  32. }
  33. $config = $event->getConfig();
  34. $config['content_on_the_fly']['allowed_languages'] = [$context['languageCode']];
  35. $event->setConfig($config);
  36. }
  37. }
  38. class_alias(RichTextAllowedLanguages::class, 'EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\Subscriber\RichTextAllowedLanguages');