Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZEE-3486: Added AllowedContentTypes to default config as it was overridden by default empty value #1717

Merged
merged 4 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}