3 namespace Drupal\Core\DependencyInjection\Compiler;
5 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6 use Symfony\Component\DependencyInjection\ContainerBuilder;
9 * Provides a compiler pass which disables the CORS middleware in case disabled.
11 * @see core.services.yml
13 class CorsCompilerPass implements CompilerPassInterface {
18 public function process(ContainerBuilder $container) {
21 if ($cors_config = $container->getParameter('cors.config')) {
22 $enabled = !empty($cors_config['enabled']);
25 // Remove the CORS middleware completly in case it was not enabled.
27 $container->removeDefinition('http_middleware.cors');