-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZEE-3486: Added AllowedContentTypes to default config as it was over…
…ridden by default empty value (#1717)
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/lib/UniversalDiscovery/Event/Subscriber/ImageAssetAllowedContentTypes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |