class CorsCompilerPass

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass
  2. 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass
  3. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass

Provides a compiler pass which disables the CORS middleware in case disabled.

Hierarchy

  • class \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of CorsCompilerPass

See also

core.services.yml

1 file declares its use of CorsCompilerPass
CoreServiceProvider.php in core/lib/Drupal/Core/CoreServiceProvider.php

File

core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php, line 13

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class CorsCompilerPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container) : void {
        $enabled = FALSE;
        if ($cors_config = $container->getParameter('cors.config')) {
            $enabled = !empty($cors_config['enabled']);
        }
        // Remove the CORS middleware completely in case it was not enabled.
        if (!$enabled) {
            $container->removeDefinition('http_middleware.cors');
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
CorsCompilerPass::process public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.