vendor/ibexa/admin-ui/src/lib/UniversalDiscovery/Event/Subscriber/ImageAssetDefaultLocationId.php line 41

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 Ibexa\Core\FieldType\ImageAsset\AssetMapper;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class ImageAssetDefaultLocationId implements EventSubscriberInterface
  12. {
  13. /** @var \Ibexa\Core\FieldType\ImageAsset\AssetMapper */
  14. private $assetMapper;
  15. /**
  16. * @param \Ibexa\Core\FieldType\ImageAsset\AssetMapper $assetMapper
  17. */
  18. public function __construct(AssetMapper $assetMapper)
  19. {
  20. $this->assetMapper = $assetMapper;
  21. }
  22. /**
  23. * @return array
  24. */
  25. public static function getSubscribedEvents(): array
  26. {
  27. return [
  28. ConfigResolveEvent::NAME => ['onUdwConfigResolve'],
  29. ];
  30. }
  31. /**
  32. * @param \Ibexa\AdminUi\UniversalDiscovery\Event\ConfigResolveEvent $event
  33. */
  34. public function onUdwConfigResolve(ConfigResolveEvent $event): void
  35. {
  36. if ($event->getConfigName() !== 'image_asset') {
  37. return;
  38. }
  39. $config = $event->getConfig();
  40. $config['starting_location_id'] = $this->assetMapper->getParentLocationId();
  41. $event->setConfig($config);
  42. }
  43. }
  44. class_alias(ImageAssetDefaultLocationId::class, 'EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\Subscriber\ImageAssetDefaultLocationId');