PHP Класс Symfony\Component\Templating\PhpEngine

Автор: Fabien Potencier ([email protected])
Наследование: implements Symfony\Component\Templating\EngineInterface, implements ArrayAccess
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$cache
$charset
$current
$escaperCache
$escapers
$globals
$helpers
$loader
$parents
$parser
$stack

Открытые методы

Метод Описание
__construct ( Symfony\Component\Templating\TemplateNameParserInterface $parser, Symfony\Component\Templating\Loader\LoaderInterface $loader, array $helpers = [] ) Constructor.
addGlobal ( string $name, mixed $value )
addHelpers ( array $helpers )
convertEncoding ( string $string, string $to, string $from ) : string Convert a string from one encoding to another.
escape ( mixed $value, string $context = 'html' ) : string Escapes a string by using the current charset.
exists ( mixed $name ) : boolean Returns true if the template exists.
extend ( string $template ) Decorates the current template with another one.
get ( string $name ) : Symfony\Component\Templating\Helper\HelperInterface Gets a helper value.
getCharset ( ) : string Gets the current charset.
getEscaper ( string $context ) : mixed Gets an escaper for a given context.
getGlobals ( ) : array Returns the assigned globals.
getLoader ( ) : Symfony\Component\Templating\Loader\LoaderInterface Gets the loader associated with this engine.
has ( string $name ) : boolean Returns true if the helper if defined.
offsetExists ( string $name ) : boolean Returns true if the helper is defined.
offsetGet ( string $name ) : mixed Gets a helper value.
offsetSet ( Symfony\Component\Templating\Helper\HelperInterface $name, string $value ) Sets a helper.
offsetUnset ( string $name ) Removes a helper.
render ( mixed $name, array $parameters = [] ) : string Renders a template.
set ( Symfony\Component\Templating\Helper\HelperInterface $helper, string $alias = null ) Sets a helper.
setCharset ( string $charset ) Sets the charset to use.
setEscaper ( string $context, mixed $escaper ) Adds an escaper for the given context.
setHelpers ( array $helpers ) Sets the helpers.
supports ( mixed $name ) : boolean Returns true if this class is able to render the given template.

Защищенные методы

Метод Описание
evaluate ( Symfony\Component\Templating\Storage\Storage $template, array $parameters = [] ) : string | false Evaluates a template.
initializeEscapers ( ) Initializes the built-in escapers.
load ( mixed $name ) : Symfony\Component\Templating\Storage\Storage Loads the given template.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( Symfony\Component\Templating\TemplateNameParserInterface $parser, Symfony\Component\Templating\Loader\LoaderInterface $loader, array $helpers = [] )
$parser Symfony\Component\Templating\TemplateNameParserInterface A TemplateNameParserInterface instance
$loader Symfony\Component\Templating\Loader\LoaderInterface A loader instance
$helpers array An array of helper instances

addGlobal() публичный Метод

public addGlobal ( string $name, mixed $value )
$name string
$value mixed

addHelpers() публичный Метод

public addHelpers ( array $helpers )
$helpers array An array of helper

convertEncoding() публичный Метод

Convert a string from one encoding to another.
public convertEncoding ( string $string, string $to, string $from ) : string
$string string The string to convert
$to string The input encoding
$from string The output encoding
Результат string The string with the new encoding

escape() публичный Метод

Escapes a string by using the current charset.
public escape ( mixed $value, string $context = 'html' ) : string
$value mixed A variable to escape
$context string The context name
Результат string The escaped value

evaluate() защищенный Метод

Evaluates a template.
protected evaluate ( Symfony\Component\Templating\Storage\Storage $template, array $parameters = [] ) : string | false
$template Symfony\Component\Templating\Storage\Storage The template to render
$parameters array An array of parameters to pass to the template
Результат string | false The evaluated template, or false if the engine is unable to render the template

exists() публичный Метод

Returns true if the template exists.
public exists ( mixed $name ) : boolean
$name mixed A template name or a TemplateReferenceInterface instance
Результат boolean true if the template exists, false otherwise

extend() публичный Метод

Decorates the current template with another one.
public extend ( string $template )
$template string The decorator logical name

get() публичный Метод

Gets a helper value.
public get ( string $name ) : Symfony\Component\Templating\Helper\HelperInterface
$name string The helper name
Результат Symfony\Component\Templating\Helper\HelperInterface The helper instance

getCharset() публичный Метод

Gets the current charset.
public getCharset ( ) : string
Результат string The current charset

getEscaper() публичный Метод

Gets an escaper for a given context.
public getEscaper ( string $context ) : mixed
$context string The context name
Результат mixed $escaper A PHP callable

getGlobals() публичный Метод

Returns the assigned globals.
public getGlobals ( ) : array
Результат array

getLoader() публичный Метод

Gets the loader associated with this engine.
public getLoader ( ) : Symfony\Component\Templating\Loader\LoaderInterface
Результат Symfony\Component\Templating\Loader\LoaderInterface A LoaderInterface instance

has() публичный Метод

Returns true if the helper if defined.
public has ( string $name ) : boolean
$name string The helper name
Результат boolean true if the helper is defined, false otherwise

initializeEscapers() защищенный Метод

Each function specifies a way for applying a transformation to a string passed to it. The purpose is for the string to be "escaped" so it is suitable for the format it is being displayed in. For example, the string: "It's required that you enter a username & password.\n" If this were to be displayed as HTML it would be sensible to turn the ampersand into '&' and the apostrophe into '&aps;'. However if it were going to be used as a string in JavaScript to be displayed in an alert box it would be right to leave the string as-is, but c-escape the apostrophe and the new line. For each function there is a define to avoid problems with strings being incorrectly specified.
protected initializeEscapers ( )

load() защищенный Метод

Loads the given template.
protected load ( mixed $name ) : Symfony\Component\Templating\Storage\Storage
$name mixed A template name or a TemplateReferenceInterface instance
Результат Symfony\Component\Templating\Storage\Storage A Storage instance

offsetExists() публичный Метод

Returns true if the helper is defined.
public offsetExists ( string $name ) : boolean
$name string The helper name
Результат boolean true if the helper is defined, false otherwise

offsetGet() публичный Метод

Gets a helper value.
public offsetGet ( string $name ) : mixed
$name string The helper name
Результат mixed The helper value

offsetSet() публичный Метод

Sets a helper.
public offsetSet ( Symfony\Component\Templating\Helper\HelperInterface $name, string $value )
$name Symfony\Component\Templating\Helper\HelperInterface The helper instance
$value string An alias

offsetUnset() публичный Метод

Removes a helper.
public offsetUnset ( string $name )
$name string The helper name

render() публичный Метод

Renders a template.
public render ( mixed $name, array $parameters = [] ) : string
$name mixed A template name or a TemplateReferenceInterface instance
$parameters array An array of parameters to pass to the template
Результат string The evaluated template as a string

set() публичный Метод

Sets a helper.
public set ( Symfony\Component\Templating\Helper\HelperInterface $helper, string $alias = null )
$helper Symfony\Component\Templating\Helper\HelperInterface The helper instance
$alias string An alias

setCharset() публичный Метод

Sets the charset to use.
public setCharset ( string $charset )
$charset string The charset

setEscaper() публичный Метод

Adds an escaper for the given context.
public setEscaper ( string $context, mixed $escaper )
$context string The escaper context (html, js, ...)
$escaper mixed A PHP callable

setHelpers() публичный Метод

Sets the helpers.
public setHelpers ( array $helpers )
$helpers array

supports() публичный Метод

Returns true if this class is able to render the given template.
public supports ( mixed $name ) : boolean
$name mixed A template name or a TemplateReferenceInterface instance
Результат boolean true if this class supports the given resource, false otherwise

Описание свойств

$cache защищенное свойство

protected $cache

$charset защищенное свойство

protected $charset

$current защищенное свойство

protected $current

$escaperCache защищенное статическое свойство

protected static $escaperCache

$escapers защищенное свойство

protected $escapers

$globals защищенное свойство

protected $globals

$helpers защищенное свойство

protected $helpers

$loader защищенное свойство

protected $loader

$parents защищенное свойство

protected $parents

$parser защищенное свойство

protected $parser

$stack защищенное свойство

protected $stack