Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Apr 19, 2021
2 parents 5cd6c59 + 2e2d2a9 commit d9755dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions bundle/DependencyInjection/Compiler/IoStorageAllowListPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Netgen\Bundle\SiteBundle\DependencyInjection\Compiler;

use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function array_merge;
use function array_search;

class IoStorageAllowListPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$scopes = array_merge(
[ConfigResolver::SCOPE_DEFAULT],
$container->getParameter('ezpublish.siteaccess.list')
);

foreach ($scopes as $scope) {
if ($container->hasParameter("ezsettings.{$scope}.io.file_storage.file_type_blacklist")) {
$bannedFileTypes = $container->getParameter("ezsettings.{$scope}.io.file_storage.file_type_blacklist");
$index = array_search('svg', $bannedFileTypes, true);

if ($index !== false) {
unset($bannedFileTypes[$index]);
$container->setParameter("ezsettings.{$scope}.io.file_storage.file_type_blacklist", array_values($bannedFileTypes));
}
}
}
}
}
1 change: 1 addition & 0 deletions bundle/NetgenSiteBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new Compiler\ContentDownloadUrlGeneratorPass());
$container->addCompilerPass(new Compiler\LocationFactoryPass());
$container->addCompilerPass(new Compiler\TwigEnvironmentPass());
$container->addCompilerPass(new Compiler\IoStorageAllowListPass());
}
}

0 comments on commit d9755dc

Please sign in to comment.