ContentBlock
extends AbstractHelper
in package
Uses
ClassBasedTemplateRendererTrait
ContentBlock view helper
Tags
Table of Contents
- $templateCache : array<string|int, mixed>
- Cache for found templates
- __invoke() : string
- Render the output of a ContentBlock plugin.
- getBriefClass() : string
- Helper to grab the end of the class name
- getCachedClassTemplate() : string
- Resolve the class template file unless already cached and return the file name.
- getTemplateWithClass() : string
- Helper to put the template path and class name together
- renderClassTemplate() : string
- Render a template associated with the provided class name, applying to specified context variables.
- resolveClassTemplate() : string
- Recursively locate a template that matches the provided class name (or one of its parent classes); throw an exception if no match is found.
Properties
$templateCache
Cache for found templates
protected
array<string|int, mixed>
$templateCache
= []
Methods
__invoke()
Render the output of a ContentBlock plugin.
public
__invoke(ContentBlockInterface $block) : string
Parameters
- $block : ContentBlockInterface
-
The ContentBlock object to render
Return values
string —getBriefClass()
Helper to grab the end of the class name
protected
getBriefClass(string $className) : string
Parameters
- $className : string
-
Class name to abbreviate
Return values
string —getCachedClassTemplate()
Resolve the class template file unless already cached and return the file name.
protected
getCachedClassTemplate(string $template, string $className) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
Return values
string —getTemplateWithClass()
Helper to put the template path and class name together
protected
getTemplateWithClass(string $template, string $className) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Class name to abbreviate
Return values
string —renderClassTemplate()
Render a template associated with the provided class name, applying to specified context variables.
protected
renderClassTemplate(string $template, string $className[, array<string|int, mixed> $context = [] ][, bool $throw = true ]) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
- $context : array<string|int, mixed> = []
-
Context for rendering template
- $throw : bool = true
-
If true (default), an exception is thrown if the template is not found. Otherwise an empty string is returned.
Tags
Return values
string —resolveClassTemplate()
Recursively locate a template that matches the provided class name (or one of its parent classes); throw an exception if no match is found.
protected
resolveClassTemplate(string $template, string $className, ResolverInterface $resolver[, string $topClassName = null ]) : string
Parameters
- $template : string
-
Template path (with %s as class name placeholder)
- $className : string
-
Name of class to apply to template.
- $resolver : ResolverInterface
-
Resolver to use
- $topClassName : string = null
-
Top-level parent class of $className (or null if $className is already the top level; used for recursion only).