function CorsCompilerPass::process

Same name in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass::process()
  2. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass::process()
  3. 11.x core/lib/Drupal/Core/DependencyInjection/Compiler/CorsCompilerPass.php \Drupal\Core\DependencyInjection\Compiler\CorsCompilerPass::process()

File

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

Class

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

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
    $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');
    }
}

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