class LazyLoadingFragmentHandler extends FragmentHandler

Lazily loads fragment renderers from the dependency injection container.

Methods

__construct(ContainerInterface $container, RequestStack $requestStack = null, bool $debug = false)

RequestStack will become required in 3.0.

addRenderer(FragmentRendererInterface $renderer)

Adds a renderer.

setRequest(Request $request = null) deprecated

Sets the current Request.

string|null
render(string|ControllerReference $uri, string $renderer = 'inline', array $options = array())

Renders a URI and returns the Response content.

string|null
deliver(Response $response)

Delivers the Response as a string.

addRendererService(string $name, string $renderer)

Adds a service as a fragment renderer.

Details

at line 35
__construct(ContainerInterface $container, RequestStack $requestStack = null, bool $debug = false)

RequestStack will become required in 3.0.

Parameters

ContainerInterface $container A container
RequestStack $requestStack The Request stack that controls the lifecycle of requests
bool $debug Whether the debug mode is enabled or not

in FragmentHandler at line 79
addRenderer(FragmentRendererInterface $renderer)

Adds a renderer.

Parameters

FragmentRendererInterface $renderer

in FragmentHandler at line 95
setRequest(Request $request = null) deprecated

deprecated since version 2.4, to be removed in 3.0.

Sets the current Request.

This method was used to synchronize the Request, but as the HttpKernel is doing that automatically now, you should never call it directly. It is kept public for BC with the 2.3 version.

Parameters

Request $request A Request instance

at line 66
string|null render(string|ControllerReference $uri, string $renderer = 'inline', array $options = array())

Renders a URI and returns the Response content.

Available options:

  • ignore_errors: true to return an empty string in case of an error

Parameters

string|ControllerReference $uri A URI as a string or a ControllerReference instance
string $renderer The renderer name
array $options An array of options

Return Value

string|null The Response content or null when the Response is streamed

Exceptions

InvalidArgumentException when the renderer does not exist
LogicException when no master request is being handled

in FragmentHandler at line 145
protected string|null deliver(Response $response)

Delivers the Response as a string.

When the Response is a StreamedResponse, the content is streamed immediately instead of being returned.

Parameters

Response $response

Return Value

string|null The Response content or null when the Response is streamed

Exceptions

RuntimeException when the Response is not successful

at line 58
addRendererService(string $name, string $renderer)

Adds a service as a fragment renderer.

Parameters

string $name The service name
string $renderer The render service id