AbstractRendererEngine
in package
implements
FormRendererEngineInterface
Default implementation of {@link FormRendererEngineInterface}.
Tags
Interfaces, Classes, Traits and Enums
- FormRendererEngineInterface
- Adapter for rendering form templates with a specific templating engine.
Table of Contents
- CACHE_KEY_VAR = 'cache_key'
- The variable in {@link FormView} used as cache key.
- $defaultThemes : array<string|int, mixed>
- $resources : array<string|int, array<string|int, mixed>>
- $themes : array<string|int, array<string|int, mixed>>
- $useDefaultThemes : array<string|int, bool>
- $resourceHierarchyLevels : array<string|int, array<string|int, int|false>>
- __construct() : mixed
- Creates a new renderer engine.
- getResourceForBlockName() : mixed
- Returns the resource for a block name.
- getResourceForBlockNameHierarchy() : mixed
- Returns the resource for a block hierarchy.
- getResourceHierarchyLevel() : int|bool
- Returns the hierarchy level at which a resource can be found.
- setTheme() : mixed
- Sets the theme(s) to be used for rendering a view and its children.
- loadResourceForBlockName() : bool
- Loads the cache with the resource for a given block name.
- loadResourceForBlockNameHierarchy() : bool
- Loads the cache with the resource for a specific level of a block hierarchy.
Constants
CACHE_KEY_VAR
The variable in {@link FormView} used as cache key.
public
mixed
CACHE_KEY_VAR
= 'cache_key'
Properties
$defaultThemes
protected
array<string|int, mixed>
$defaultThemes
$resources
protected
array<string|int, array<string|int, mixed>>
$resources
= []
$themes
protected
array<string|int, array<string|int, mixed>>
$themes
= []
$useDefaultThemes
protected
array<string|int, bool>
$useDefaultThemes
= []
$resourceHierarchyLevels
private
array<string|int, array<string|int, int|false>>
$resourceHierarchyLevels
= []
Methods
__construct()
Creates a new renderer engine.
public
__construct([array<string|int, mixed> $defaultThemes = [] ]) : mixed
Parameters
- $defaultThemes : array<string|int, mixed> = []
-
The default themes. The type of these themes is open to the implementation.
Return values
mixed —getResourceForBlockName()
Returns the resource for a block name.
public
getResourceForBlockName(FormView $view, mixed $blockName) : mixed
Parameters
- $view : FormView
-
The view for determining the used themes. First the themes attached directly to the view with are considered, then the ones of its parent etc.
- $blockName : mixed
-
The name of the block to render
Return values
mixed —the renderer resource or false, if none was found
getResourceForBlockNameHierarchy()
Returns the resource for a block hierarchy.
public
getResourceForBlockNameHierarchy(FormView $view, array<string|int, mixed> $blockNameHierarchy, mixed $hierarchyLevel) : mixed
Parameters
- $view : FormView
-
The view for determining the used themes. First the themes attached directly to the view with are considered, then the ones of its parent etc.
- $blockNameHierarchy : array<string|int, mixed>
-
The block name hierarchy, with the root block at the beginning
- $hierarchyLevel : mixed
-
The level in the hierarchy at which to start looking. Level 0 indicates the root block, i.e. the first element of $blockNameHierarchy.
Return values
mixed —The renderer resource or false, if none was found
getResourceHierarchyLevel()
Returns the hierarchy level at which a resource can be found.
public
getResourceHierarchyLevel(FormView $view, array<string|int, mixed> $blockNameHierarchy, mixed $hierarchyLevel) : int|bool
Parameters
- $view : FormView
-
The view for determining the used themes. First the themes attached directly to the view with are considered, then the ones of its parent etc.
- $blockNameHierarchy : array<string|int, mixed>
-
The block name hierarchy, with the root block at the beginning
- $hierarchyLevel : mixed
-
The level in the hierarchy at which to start looking. Level 0 indicates the root block, i.e. the first element of $blockNameHierarchy.
Return values
int|bool —The hierarchy level or false, if no resource was found
setTheme()
Sets the theme(s) to be used for rendering a view and its children.
public
setTheme(FormView $view, mixed $themes[, mixed $useDefaultThemes = true ]) : mixed
Parameters
- $view : FormView
-
The view to assign the theme(s) to
- $themes : mixed
-
The theme(s). The type of these themes is open to the implementation.
- $useDefaultThemes : mixed = true
-
If true, will use default themes specified in the engine
Return values
mixed —loadResourceForBlockName()
Loads the cache with the resource for a given block name.
protected
abstract loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName) : bool
Parameters
- $cacheKey : string
-
The cache key of the form view
- $view : FormView
-
The form view for finding the applying themes
- $blockName : string
-
The name of the block to load
Tags
Return values
bool —True if the resource could be loaded, false otherwise
loadResourceForBlockNameHierarchy()
Loads the cache with the resource for a specific level of a block hierarchy.
private
loadResourceForBlockNameHierarchy(string $cacheKey, FormView $view, array<string|int, mixed> $blockNameHierarchy, int $hierarchyLevel) : bool
Parameters
- $cacheKey : string
- $view : FormView
- $blockNameHierarchy : array<string|int, mixed>
- $hierarchyLevel : int