Additional available options:
Overrides FragmentRendererInterface::render
public function render($uri, Request $request, array $options = array()) {
$reference = null;
if ($uri instanceof ControllerReference) {
$reference = $uri;
$uri = $this
->generateFragmentUri($uri, $request);
}
$subRequest = $this
->createSubRequest($uri, $request);
// override Request attributes as they can be objects (which are not supported by the generated URI)
if (null !== $reference) {
$subRequest->attributes
->add($reference->attributes);
}
$level = ob_get_level();
try {
return $this->kernel
->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
} catch (\Exception $e) {
// we dispatch the exception event to trigger the logging
// the response that comes back is simply ignored
if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) {
$event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e);
$this->dispatcher
->dispatch(KernelEvents::EXCEPTION, $event);
}
// let's clean up the output buffers that were created by the sub-request
while (ob_get_level() > $level) {
ob_get_clean();
}
if (isset($options['alt'])) {
$alt = $options['alt'];
unset($options['alt']);
return $this
->render($alt, $request, $options);
}
if (!isset($options['ignore_errors']) || !$options['ignore_errors']) {
throw $e;
}
return new Response();
}
}