PHP Класс lithium\template\Helper

Supplies the basic functionality of _render and _options, as well as escaping.
Наследование: extends lithium\core\Object
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$contentMap array Maps helper method names to content types as defined by the Media class, where key are method names, and values are the content type that the method name outputs a link to.

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

Свойство Тип Описание
$_autoConfig array Auto configuration properties.
$_classes array This property can be overwritten with any class dependencies a helper subclass has.
$_context lithium\template\view\Renderer The Renderer object this Helper is bound to.
$_minimized array List of minimized HTML attributes.
$_strings array Holds string templates which will be merged into the rendering context.

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

Метод Описание
__construct ( array $config = [] ) : void Constructor.
escape ( string $value, mixed $method = null, array $options = [] ) : mixed Escapes values according to the output type of the rendering context. Helpers that output to non-HTML/XML contexts should override this method accordingly.

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

Метод Описание
_attribute ( string $key, mixed $value, array $options = [] ) : string Convert a key/value pair to a valid HTML attribute.
_attributes ( array | string $params, string $method = null, array $options = [] ) : string Converts a set of parameters to HTML attributes into a string.
_init ( ) : void Imports local string definitions into rendering context.
_options ( array $defaults, array $scope ) : array Takes the defaults and current options, merges them and returns options which have the default keys removed and full set of options as the scope.
_render ( string $method, string $string, array $params, array $options = [] ) : string Render a string template after applying context filters Use examples in the Html::link() method: return $this->_render(__METHOD__, 'link', compact('title', 'url', 'options'), $scope);

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

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

Constructor.
public __construct ( array $config = [] ) : void
$config array Configuration options.
Результат void

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

Convert a key/value pair to a valid HTML attribute.
protected _attribute ( string $key, mixed $value, array $options = [] ) : string
$key string The key name of the HTML attribute.
$value mixed The HTML attribute value.
$options array The options used when converting the key/value pair to attributes: - `'escape'` _boolean_: Indicates whether `$key` and `$value` should be HTML-escaped. Defaults to `true`. - `'format'` _string_: The format string. Defaults to `'%s="%s"'`.
Результат string Returns an HTML attribute/value pair, in the form of `'$key="$value"'`.

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

Converts a set of parameters to HTML attributes into a string.
См. также: lithium\template\view\Renderer::__call()
protected _attributes ( array | string $params, string $method = null, array $options = [] ) : string
$params array | string The parameters where key is the attribute name and the value the attribute value. When string will simply prepend with the prepend-string (by default `' '`) unless $params is falsey in which case an empty string is returned. This alternative syntax is used by the method internally.
$method string When used as a context handler, the method the handler was called for I.e. `'wrap'`. Currently not used by the method.
$options array Available options are: - `'escape'` _boolean_: Indicates whether the output should be HTML-escaped. Defaults to `true`. - `'prepend'` _string_: String to prepend to each attribute pair. and the final result. Defaults to `' '`. - `'append'` _string_: String to append to result. Defaults to `''`.
Результат string Attribute string.

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

Imports local string definitions into rendering context.
protected _init ( ) : void
Результат void

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

Takes the defaults and current options, merges them and returns options which have the default keys removed and full set of options as the scope.
protected _options ( array $defaults, array $scope ) : array
$defaults array
$scope array the complete set of options
Результат array $scope, $options

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

Render a string template after applying context filters Use examples in the Html::link() method: return $this->_render(__METHOD__, 'link', compact('title', 'url', 'options'), $scope);
protected _render ( string $method, string $string, array $params, array $options = [] ) : string
$method string name of method that is calling the render (for context filters)
$string string template key (in Helper::_strings) to render
$params array associated array of template inserts {:key} will be replaced by value
$options array Available options: - `'handlers'` _array_: Before inserting `$params` inside the string template, `$this->_context`'s handlers are applied to each value of `$params` according to the key (e.g `$params['url']`, which is processed by the `'url'` handler via `$this->_context->applyHandler()`). The `'handlers'` option allow to set custom mapping beetween `$params`'s key and `$this->_context`'s handlers. e.g. the following handler: `'handlers' => array('url' => 'path')` will make `$params['url']` to be processed by the `'path'` handler instead of the `'url'` one.
Результат string Rendered HTML

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

Escapes values according to the output type of the rendering context. Helpers that output to non-HTML/XML contexts should override this method accordingly.
public escape ( string $value, mixed $method = null, array $options = [] ) : mixed
$value string
$method mixed
$options array
Результат mixed

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

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

Auto configuration properties.
protected array $_autoConfig
Результат array

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

This property can be overwritten with any class dependencies a helper subclass has.
protected array $_classes
Результат array

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

The Renderer object this Helper is bound to.
См. также: lithium\template\view\Renderer
protected lithium\template\view\Renderer $_context
Результат lithium\template\view\Renderer

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

List of minimized HTML attributes.
protected array $_minimized
Результат array

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

Holds string templates which will be merged into the rendering context.
protected array $_strings
Результат array

$contentMap публичное свойство

Maps helper method names to content types as defined by the Media class, where key are method names, and values are the content type that the method name outputs a link to.
public array $contentMap
Результат array