Adds a managed request scope.
@author Fabien Potencier <fabien@symfony.com> @author Johannes M. Schmitt <schmittjoh@gmail.com>
Expanded class hierarchy of ContainerAwareHttpKernel
class ContainerAwareHttpKernel extends HttpKernel {
protected $container;
/**
* Constructor.
*
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param ContainerInterface $container A ContainerInterface instance
* @param ControllerResolverInterface $controllerResolver A ControllerResolverInterface instance
*/
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver) {
parent::__construct($dispatcher, $controllerResolver);
$this->container = $container;
// the request scope might have been created before (see FrameworkBundle)
if (!$container
->hasScope('request')) {
$container
->addScope(new Scope('request'));
}
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) {
$request->headers
->set('X-Php-Ob-Level', ob_get_level());
$this->container
->enterScope('request');
$this->container
->set('request', $request, 'request');
try {
$response = parent::handle($request, $type, $catch);
} catch (\Exception $e) {
$this->container
->set('request', null, 'request');
$this->container
->leaveScope('request');
throw $e;
}
$this->container
->set('request', null, 'request');
$this->container
->leaveScope('request');
return $response;
}
}
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContainerAwareHttpKernel:: |
protected | property | ||
ContainerAwareHttpKernel:: |
public | function |
@api Overrides HttpKernel:: |
|
ContainerAwareHttpKernel:: |
public | function |
Constructor. Overrides HttpKernel:: |
|
HttpKernel:: |
protected | property | ||
HttpKernel:: |
protected | property | ||
HttpKernel:: |
private | function | Filters a response object. | |
HttpKernel:: |
private | function | Handles an exception by trying to convert it to a Response. | |
HttpKernel:: |
private | function | Handles a request to convert it to a response. | |
HttpKernel:: |
public | function |
@api Overrides TerminableInterface:: |
|
HttpKernel:: |
private | function | ||
HttpKernelInterface:: |
constant | |||
HttpKernelInterface:: |
constant |