Related
extends AbstractHelper
in package
Uses
ClassBasedTemplateRendererTrait
Related records view helper
Tags
Table of Contents
- $configManager : PluginManager
- Config manager
- $optionsManager : PluginManager
- Plugin manager for search options.
- $pluginManager : PluginManager
- Plugin manager for related record modules.
- $templateCache : array<string|int, mixed>
- Cache for found templates
- __construct() : mixed
- Constructor
- getList() : array<string|int, mixed>
- Get a list of related records modules.
- render() : string
- Render the output of a related records module.
- 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.
- getConfigForSource() : array<string|int, mixed>
- Given a record source ID, return the appropriate related record configuration.
- 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
$configManager
Config manager
protected
PluginManager
$configManager
$optionsManager
Plugin manager for search options.
protected
PluginManager
$optionsManager
$pluginManager
Plugin manager for related record modules.
protected
PluginManager
$pluginManager
$templateCache
Cache for found templates
protected
array<string|int, mixed>
$templateCache
= []
Methods
__construct()
Constructor
public
__construct(PluginManager $pluginManager, PluginManager $cm, PluginManager $om) : mixed
Parameters
- $pluginManager : PluginManager
-
Plugin manager for related record modules
- $cm : PluginManager
-
Configuration manager
- $om : PluginManager
-
Search options manager
Return values
mixed —getList()
Get a list of related records modules.
public
getList(AbstractBase $driver) : array<string|int, mixed>
Parameters
- $driver : AbstractBase
-
Record driver
Return values
array<string|int, mixed> —render()
Render the output of a related records module.
public
render(RelatedInterface $related) : string
Parameters
- $related : RelatedInterface
-
The related records 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 —getConfigForSource()
Given a record source ID, return the appropriate related record configuration.
protected
getConfigForSource(string $source) : array<string|int, mixed>
Parameters
- $source : string
-
Source identifier
Return values
array<string|int, mixed> —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).