class TimedPhpEngine extends PhpEngine

Times the time spent to render a template.

Methods

__construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null)

Constructor.

string
render(string|TemplateReferenceInterface $name, array $parameters = array())

Renders a template.

bool
exists(string|TemplateReferenceInterface $name)

Returns true if the template exists.

from PhpEngine
bool
supports(string|TemplateReferenceInterface $name)

Returns true if this class is able to render the given template.

from PhpEngine
offsetGet(string $name)

Gets a helper value.

from PhpEngine
bool
offsetExists(string $name)

Returns true if the helper is defined.

from PhpEngine
offsetSet(HelperInterface $name, string $value)

Sets a helper.

from PhpEngine
offsetUnset(string $name)

Removes a helper.

from PhpEngine
addHelpers(array $helpers)

Adds some helpers.

from PhpEngine
setHelpers(array $helpers)

Sets the helpers.

from PhpEngine
set(HelperInterface $helper, string $alias = null)

Sets a helper.

from PhpEngine
bool
has(string $name)

Returns true if the helper if defined.

from PhpEngine
get(string $name)

Gets a helper value.

from PhpEngine
extend(string $template)

Decorates the current template with another one.

from PhpEngine
string
escape(mixed $value, string $context = 'html')

Escapes a string by using the current charset.

from PhpEngine
setCharset(string $charset)

Sets the charset to use.

from PhpEngine
string
getCharset()

Gets the current charset.

from PhpEngine
setEscaper(string $context, callable $escaper)

Adds an escaper for the given context.

from PhpEngine
callable
getEscaper(string $context)

Gets an escaper for a given context.

from PhpEngine
addGlobal(string $name, mixed $value)

No description

from PhpEngine
array
getGlobals()

Returns the assigned globals.

from PhpEngine
string
convertEncoding(string $string, string $to, string $from) deprecated

Convert a string from one encoding to another.

from PhpEngine
getLoader()

Gets the loader associated with this engine.

from PhpEngine
renderResponse(string $view, array $parameters = array(), Response $response = null)

Renders a view and returns a Response.

from PhpEngine

Details

at line line 37
__construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null)

Constructor.

Parameters

TemplateNameParserInterface $parser A TemplateNameParserInterface instance
ContainerInterface $container The DI container
LoaderInterface $loader A loader instance
Stopwatch $stopwatch A Stopwatch instance
GlobalVariables $globals A GlobalVariables instance or null

at line line 47
string render(string|TemplateReferenceInterface $name, array $parameters = array())

Renders a template.

Parameters

string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance
array $parameters An array of parameters to pass to the template

Return Value

string The evaluated template as a string

Exceptions

RuntimeException if the template cannot be rendered

in PhpEngine at line line 101
bool exists(string|TemplateReferenceInterface $name)

Returns true if the template exists.

Parameters

string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance

Return Value

bool true if the template exists, false otherwise

Exceptions

RuntimeException if the engine cannot handle the template name

in PhpEngine at line line 115
bool supports(string|TemplateReferenceInterface $name)

Returns true if this class is able to render the given template.

Parameters

string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance

Return Value

bool true if this class supports the given template, false otherwise

in PhpEngine at line line 180
HelperInterface offsetGet(string $name)

Gets a helper value.

Parameters

string $name The helper name

Return Value

HelperInterface The helper value

Exceptions

InvalidArgumentException if the helper is not defined

in PhpEngine at line line 192
bool offsetExists(string $name)

Returns true if the helper is defined.

Parameters

string $name The helper name

Return Value

bool true if the helper is defined, false otherwise

in PhpEngine at line line 203
offsetSet(HelperInterface $name, string $value)

Sets a helper.

Parameters

HelperInterface $name The helper instance
string $value An alias

in PhpEngine at line line 215
offsetUnset(string $name)

Removes a helper.

Parameters

string $name The helper name

Exceptions

LogicException

in PhpEngine at line line 225
addHelpers(array $helpers)

Adds some helpers.

Parameters

array $helpers An array of helper

in PhpEngine at line line 68
setHelpers(array $helpers)

Sets the helpers.

Parameters

array $helpers An array of helper

in PhpEngine at line line 249
set(HelperInterface $helper, string $alias = null)

Sets a helper.

Parameters

HelperInterface $helper The helper instance
string $alias An alias

in PhpEngine at line line 266
bool has(string $name)

Returns true if the helper if defined.

Parameters

string $name The helper name

Return Value

bool true if the helper is defined, false otherwise

in PhpEngine at line line 51
HelperInterface get(string $name)

Gets a helper value.

Parameters

string $name The helper name

Return Value

HelperInterface The helper instance

Exceptions

InvalidArgumentException if the helper is not defined

in PhpEngine at line line 294
extend(string $template)

Decorates the current template with another one.

Parameters

string $template The decorator logical name

in PhpEngine at line line 307
string escape(mixed $value, string $context = 'html')

Escapes a string by using the current charset.

Parameters

mixed $value A variable to escape
string $context The context name

Return Value

string The escaped value

in PhpEngine at line line 331
setCharset(string $charset)

Sets the charset to use.

Parameters

string $charset The charset

in PhpEngine at line line 348
string getCharset()

Gets the current charset.

Return Value

string The current charset

in PhpEngine at line line 359
setEscaper(string $context, callable $escaper)

Adds an escaper for the given context.

Parameters

string $context The escaper context (html, js, ...)
callable $escaper A PHP callable

in PhpEngine at line line 374
callable getEscaper(string $context)

Gets an escaper for a given context.

Parameters

string $context The context name

Return Value

callable $escaper A PHP callable

Exceptions

InvalidArgumentException

in PhpEngine at line line 387
addGlobal(string $name, mixed $value)

Parameters

string $name
mixed $value

in PhpEngine at line line 397
array getGlobals()

Returns the assigned globals.

Return Value

array

in PhpEngine at line line 497
string convertEncoding(string $string, string $to, string $from) deprecated

deprecated since 2.8, to be removed in 3.0. Use iconv() instead.

Convert a string from one encoding to another.

Parameters

string $string The string to convert
string $to The input encoding
string $from The output encoding

Return Value

string The string with the new encoding

in PhpEngine at line line 509
LoaderInterface getLoader()

Gets the loader associated with this engine.

Return Value

LoaderInterface A LoaderInterface instance

in PhpEngine at line line 76
Response renderResponse(string $view, array $parameters = array(), Response $response = null)

Renders a view and returns a Response.

Parameters

string $view The view name
array $parameters An array of parameters to pass to the view
Response $response A Response instance

Return Value

Response A Response instance

Exceptions

RuntimeException if the template cannot be rendered