\Gishiki\Core\MVC\Controller\PluginsTwigWrapper

This is a plugin used to call the Twig template engine.

Summary

Methods
Properties
Constants
__construct()
getResponse()
getRequest()
setTwigLoader()
renderTwigTemplate()
getTwig()
No public properties found
TEMPLATE_DIRECTORY
CACHE_DIRECTORY
No protected methods found
$request
$response
$application
N/A
isLoaderReady()
isLoadedTwig()
prepareTwig()
$loader
$twig
N/A

Constants

TEMPLATE_DIRECTORY

TEMPLATE_DIRECTORY

CACHE_DIRECTORY

CACHE_DIRECTORY

Properties

$request

$request : \Psr\Http\Message\RequestInterface

Type

\Psr\Http\Message\RequestInterface — reference to the HTTP request

$response

$response : \Psr\Http\Message\ResponseInterface

Type

\Psr\Http\Message\ResponseInterface — reference to the HTTP response

$application

$application : \Gishiki\Core\Application|null

Type

\Gishiki\Core\Application|null — the application current instance

$loader

$loader : \Twig_LoaderInterface|null

Type

\Twig_LoaderInterface|null — the filesystem loader

$twig

$twig : \Twig_Environment|null

Type

\Twig_Environment|null — the environment

Methods

__construct()

__construct(\Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response, \Gishiki\Core\Application|null  $app = null) 

TwigWrapper constructor: setup the plugin

Warning: you should never attempt to use another construction in your plugin, unless it calls parent::__construct()

Parameters

\Psr\Http\Message\RequestInterface $request

the HTTP request

\Psr\Http\Message\ResponseInterface $response

the HTTP response

\Gishiki\Core\Application|null $app

the current application instance

getResponse()

getResponse() : \Psr\Http\Message\ResponseInterface

Get the HTTP response.

Returns

\Psr\Http\Message\ResponseInterface —

the HTTP response

getRequest()

getRequest() : \Psr\Http\Message\RequestInterface

Get the HTTP request.

Returns

\Psr\Http\Message\RequestInterface —

the HTTP request

setTwigLoader()

setTwigLoader(\Twig_LoaderInterface|null  $loader = null) 

Load the Twig environment with the given loader.

Parameters

\Twig_LoaderInterface|null $loader

the Twig loader, null for the default one

Throws

\Gishiki\Core\MVC\Controller\ControllerException

the given Twig loader is not valid

renderTwigTemplate()

renderTwigTemplate(string  $template, \Gishiki\Algorithms\Collections\CollectionInterface  $data) 

Render a Twig template and write the result to the response content.

Also set the mime type as text/html.

Parameters

string $template

the template file name

\Gishiki\Algorithms\Collections\CollectionInterface $data

the data to be processed to create the final result

Throws

\Gishiki\Core\MVC\Controller\ControllerException

the Twig loader is not ready

getTwig()

getTwig() : \Twig

Return a reference to the native twig object.

Returns

\Twig —

the native twig oject

isLoaderReady()

isLoaderReady() : boolean

Check if the Twig environment is loaded.

Returns

boolean —

true if the environment is already loaded

isLoadedTwig()

isLoadedTwig() : boolean

Check if the twig environment is already loaded.

Returns

boolean —

true only if the twig environment is already loaded

prepareTwig()

prepareTwig() 

Prepare the Twig environment from loader loaded into constructor.

Lazily loading the Twig environment is super-useful for Unit testing!