Skip to content

Commit

Permalink
EZEE-3486: Added AllowedContentTypes to default config as it was over…
Browse files Browse the repository at this point in the history
…ridden by default empty value (#1717)
  • Loading branch information
ViniTou authored Mar 8, 2021
1 parent 4ede897 commit 08ae795
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
onConfirm,
onCancel,
title,
allowedContentTypes: [imageAssetMapping['contentTypeIdentifier']],
...config,
}),
udwContainer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\Subscriber;

use EzSystems\EzPlatformAdminUi\UniversalDiscovery\Event\ConfigResolveEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use eZ\Publish\Core\FieldType\ImageAsset\AssetMapper;

final class ImageAssetAllowedContentTypes implements EventSubscriberInterface
{
/** @var \eZ\Publish\Core\FieldType\ImageAsset\AssetMapper */
private $assetMapper;

public function __construct(AssetMapper $assetMapper)
{
$this->assetMapper = $assetMapper;
}

public static function getSubscribedEvents(): array
{
return [
ConfigResolveEvent::NAME => ['onUdwConfigResolve'],
];
}

public function onUdwConfigResolve(ConfigResolveEvent $event): void
{
if ($event->getConfigName() !== 'image_asset') {
return;
}

$config = $event->getConfig();
$config['allowedContentTypes'][] = $this->assetMapper->getContentTypeIdentifier();

$event->setConfig($config);
}
}

0 comments on commit 08ae795

Please sign in to comment.