\phpDocumentor\Plugin\Scrybe\TemplateFactory

A factory used to retrieve a template engine given a simplified name.

With this factory it is possible to abstract away the actual class names and provide a faux name that is suitable for configuration purposes. An additional benefit is that any plugin is able to register their own template engines if desired.

Summary

Methods
Properties
Constants
__construct()
register()
get()
No public properties found
No constants found
No protected methods found
$engines
N/A
No private methods found
No private properties found
N/A

Properties

$engines

$engines : array<mixed,string>

Type

array<mixed,string> — Associative array with engine names as key and class names as value.

Methods

__construct()

__construct(array<mixed,\phpDocumentor\Plugin\Scrybe\Template\TemplateInterface>  $engines = array()) 

Registers the default and provided Template engines.

Parameters

array<mixed,\phpDocumentor\Plugin\Scrybe\Template\TemplateInterface> $engines

Associative array of the engine class names and their name as key.

register()

register(string  $name, \phpDocumentor\Plugin\Scrybe\Template\TemplateInterface  $templateEngine) : void

Associates a human-readable / simplified name with a class name representing a template engine.

The class belonging to the given class name should implement the TemplateInterface. If it does not then this method won't complain (as no instantiation is done here for performance reasons) but the get() method will throw an exception.

Parameters

string $name
\phpDocumentor\Plugin\Scrybe\Template\TemplateInterface $templateEngine

get()

get(string  $name) : \phpDocumentor\Plugin\Scrybe\Template\TemplateInterface

Returns a new instance of the template engine belonging to the given name.

Parameters

string $name

Throws

\InvalidArgumentException

if the given name is not registered

Returns

\phpDocumentor\Plugin\Scrybe\Template\TemplateInterface