CorsCompilerPass::process

public CorsCompilerPass::process(ContainerBuilder $container)

You can modify the container here before it is dumped to PHP code.

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::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 completly in case it was not enabled.
  if (!$enabled) {
    $container->removeDefinition('http_middleware.cors');
  }
}
doc_Drupal
2016-10-29 08:59:03
Comments
Leave a Comment

Please login to continue.