TwigLoaderInterface
in
This is the TwigLoaderInterface.
This interface defines the methods to be defined by those 'Twig loader classes' that implement this interface.
Tags
Table of Contents
load() | This method creates and initializes the Twig Environment. | : void |
---|---|---|
render() | This method uses Twig Environment to render the page and returns the renderization. | : string |
Methods
load()
This method creates and initializes the Twig Environment.
public
load([array<string|int, mixed> $data = [] ], int $autoescape[, bool $loadCore = true ]) : void
For the initialization it takes into account the Theme specified in the TwigLoader creation and all the data given by parameters to this method.
Parameters
- $data : array<string|int, mixed> = []
-
-> All the needed data to be accesible from Twig templates.
- $autoescape : int
-
-> @See TwigAutoescape::AUTOESCAPE_*. https://twig.symfony.com/doc/2.x/tags/autoescape.html
- $loadCore : bool = true
-
-> To indicate if it is required to load the Twig Core Macros functionality.
Return values
void —render()
This method uses Twig Environment to render the page and returns the renderization.
public
render([string $content = null ][, string $layout = null ][, string $version = null ][, string $format = 'html' ]) : string
The renderization is based on the Theme provided in the TwigLoader creation, the data provided with the load method and the format specified by parameter(by default html).
Parameters
- $content : string = null
-
-> If different to null, it overrides the theme content to load in Twig
- $layout : string = null
-
-> If different to null, it overrides the theme layout to load in Twig
- $version : string = null
-
-> If different to null, it overrides the theme version to load in Twig
- $format : string = 'html'
-
-> Default value: 'html'. Set the format to mark the name of the layout. For example, with "json" value, Twig renderization will load default.json.twig