\Charcoal\View\TwigTwigEngine

Default implementation, as abstract class, of the `EngineInterface`.

View Engines are comprised of 2 things:

  • A template loader, wich is a LoaderInterfaceObject
    • Set with set_loader() / Get with loader()
    • Provides loadtemplate() method
  • A render() method, which takes a $template and a $context arguments

Engines implements the LoggerAwareInterface. A logger can be accessed with the logger() method.

Summary

Methods
Properties
Constants
type()
__construct()
loadTemplate()
render()
renderTemplate()
twig()
No public properties found
No constants found
loader()
createTwig()
No protected properties found
N/A
setLoader()
$loader
$twig
N/A

Properties

$twig

$twig : \Twig_Environment

Type

\Twig_Environment

Methods

type()

type() : string

Returns

string

__construct()

__construct(array  $data) 

Build the object with an array of dependencies.

Required parameters:

  • logger a PSR-3 logger

Optional parameters:

  • loader a Loader object

Parameters

array $data

Engine dependencie.

loadTemplate()

loadTemplate(string  $templateIdent) : string

Delegates template loading to the engine's Loader object.

Parameters

string $templateIdent

The template identifier to load.

Returns

string —

The template string, loaded from identifier.

render()

render(string  $templateIdent, mixed  $context) : string

Load a template (from identifier) and render it.

Parameters

string $templateIdent

The template identifier to load and render.

mixed $context

The rendering context.

Returns

string —

The rendered template string.

renderTemplate()

renderTemplate(string  $templateString, mixed  $context) : string

Render a template (from string).

Parameters

string $templateString

The template string to render.

mixed $context

The rendering context.

Returns

string —

The rendered template string.

twig()

twig() : \Twig_Environment

Returns

\Twig_Environment

createTwig()

createTwig() : \Twig_Environment

Returns

\Twig_Environment