PHP 클래스 lithium\template\view\Renderer

When in a view, the local scope is that of an instance of Renderer - meaning that $this in views is an instance of the current renderer adapter. For more information about implementing your own template loaders or renderers, see the lithium\template\View class.
또한 보기: lithium\template\View
또한 보기: lithium\template\adapter\File
또한 보기: lithium\template\adapter\Simple
상속: extends lithium\core\Object
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_autoConfig array These configuration variables will automatically be assigned to their corresponding protected properties when the object is initialized.
$_classes array Renderer's dependencies. These classes are used by the output handlers to generate URLs for dynamic resources and static assets.
$_context array Context values that exist across all templates rendered in this context. These values are usually rendered in the layout template after all other values have rendered.
$_data array An array containing any additional variables to be injected into view templates. This allows local variables to be communicated between multiple templates (i.e. an element and a layout) which are using the same rendering context.
$_handlers array Automatically matches up template strings by name to output handlers. A handler can either be a string, which represents a method name of the helper, or it can be a closure or callable object. A handler takes 3 parameters: the value to be filtered, the name of the helper method that triggered the handler, and the array of options passed to the _render(). These handlers are shared among all helper objects, and are automatically triggered whenever a helper method renders a template string (using _render()) and a key which is to be embedded in the template string matches an array key of a corresponding handler.
$_helpers array Contains the list of helpers currently in use by this rendering context. Helpers are loaded via the helper() method, which is called by Renderer::__get(), allowing for on-demand loading of helpers.
$_options array Available options accepted by template\View::render(), used when rendering.
$_request The Request object instance, if applicable.
$_response The Response object instance, if applicable.
$_strings array Aggregates named string templates used by helpers. Can be overridden to change the default strings a helper uses.
$_vars Variables that have been set from a view/element/layout/etc. that should be available to the same rendering context.
$_view object Holds an instance of the View object that created this rendering context. See the view() method for more details.

공개 메소드들

메소드 설명
__call ( string $method, array $params ) : mixed Dispatches method calls for (a) rendering context values or (b) applying handlers to pieces of content. If $method is a key in Renderer::$_context, the corresponding context value will be returned (with the value run through a matching handler if one is available). If $method is a key in Renderer::$_handlers, the value passed as the first parameter in the method call will be passed through the handler and returned.
__construct ( array $config = [] ) : void Constructor.
__get ( string $property ) : mixed Returns a helper object or context value by name.
__isset ( string $property ) : boolean Magic __isset method.
applyHandler ( object $helper, string $method, string $name, mixed $value, array $options = [] ) : mixed Filters a piece of content through a content handler. A handler can be: - a string containing the name of a method defined in $helper. The method is called with 3 parameters: the value to be handled, the helper method called ($method) and the $options that were passed into applyHandler.
context ( string $property = null ) : mixed Returns either one or all context values for this rendering context. Context values persist across all templates rendered in the current context, and are usually outputted in a layout template.
data ( ) : array Returns all variables and their values that have been set.
handlers ( mixed $handlers = null ) : mixed Gets or adds content handlers from/to this rendering context, depending on the value of $handlers. For more on how to implement handlers and the various types, see applyHandler().
helper ( string $name, array $config = [] ) : object Brokers access to helpers attached to this rendering context, and loads helpers on-demand if they are not available.
render ( string $template, array | string $data = [], array $options = [] ) : string Render the template with given data. Abstract; must be added to subclasses.
request ( ) : object Returns the Request object associated with this rendering context.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.
response ( ) : object Returns the Response object associated with this rendering context.
set ( array $data = [] ) : void Allows variables to be set by one template and used in subsequent templates rendered using the same context. For example, a variable can be set in a template and used in an element rendered within a template, or an element or template could set a variable which would be made available in the layout.
strings ( mixed $strings = null ) : mixed Manages template strings.
view ( ) : object Retuns the View object that controls this rendering context's instance. This can be used, for example, to render view elements, i.e. view()->render('element' $name); ?>.

보호된 메소드들

메소드 설명
_init ( ) : void Sets the default output handlers for string template inputs.
_render ( string $type, string $template, array $data = [], array $options = [] ) : string Shortcut method used to render elements and other nested templates from inside the templating layer.

메소드 상세

__call() 공개 메소드

Dispatches method calls for (a) rendering context values or (b) applying handlers to pieces of content. If $method is a key in Renderer::$_context, the corresponding context value will be returned (with the value run through a matching handler if one is available). If $method is a key in Renderer::$_handlers, the value passed as the first parameter in the method call will be passed through the handler and returned.
또한 보기: lithium\template\view\Renderer::$_context
또한 보기: lithium\template\view\Renderer::$_handlers
또한 보기: lithium\template\view\Renderer::applyHandler()
public __call ( string $method, array $params ) : mixed
$method string The method name to call, usually either a rendering context value or a content handler.
$params array
리턴 mixed

__construct() 공개 메소드

Constructor.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `view`: The `View` object associated with this renderer. - `strings`: String templates used by helpers. - `handlers`: An array of output handlers for string template inputs. - `request`: The `Request` object associated with this renderer and passed to the defined handlers. - `response`: The `Response` object associated with this renderer. - `context`: An array of the current rendering context data, including `content`, `title`, `scripts`, `head` and `styles`.
리턴 void

__get() 공개 메소드

Returns a helper object or context value by name.
public __get ( string $property ) : mixed
$property string The name of the helper or context value to return.
리턴 mixed

__isset() 공개 메소드

Is triggered by calling isset() or empty() on inaccessible properties, and performs an isset() check on for keys in the current context.
public __isset ( string $property ) : boolean
$property string The accessed property.
리턴 boolean True if set, false otherwise.

_init() 보호된 메소드

The default handlers available are: - url: Allows generating escaped and routed URLs using Router::match(). Note that all falsey values, which includes an empty array, will result in '/' being returned. For empty arrays this behavior is slightly different from using Router::match() directly. - path: Generates an asset path. - options: Converts a set of parameters to HTML attributes into a string. - title: Returns the escaped title. - value: Returns an escaped value. - scripts: Returns a markup string of styles from context. - styles: Returns a markup string of scripts from context. - head
또한 보기: lithium\net\http\Router::match()
또한 보기: lithium\net\http\Media::asset()
또한 보기: lithium\template\Helper::_attributes()
protected _init ( ) : void
리턴 void

_render() 보호된 메소드

Shortcut method used to render elements and other nested templates from inside the templating layer.
또한 보기: lithium\template\View::$_processes
또한 보기: lithium\template\View::render()
protected _render ( string $type, string $template, array $data = [], array $options = [] ) : string
$type string The type of template to render, usually either `'element'` or `'template'`. Indicates the process used to render the content. See `lithium\template\View::$_processes` for more info.
$template string The template file name. For example, if `'header'` is passed, and `$type` is set to `'element'`, then the template rendered will be `views/elements/header.html.php` (assuming the default configuration).
$data array An array of any other local variables that should be injected into the template. By default, only the values used to render the current template will be sent. If `$data` is non-empty, both sets of variables will be merged.
$options array Any options accepted by `template\View::render()`.
리턴 string Returns a the rendered template content as a string.

applyHandler() 공개 메소드

- an array where the first element is an object reference, and the second element is a method name. The method name given will be called on the object with the same parameters as above. - a closure, which takes the value as the first parameter, an array containing an instance of the calling helper and the calling method name as the second, and $options as the third. In all cases, handlers should return the transformed version of $value.
또한 보기: lithium\template\view\Renderer::handlers()
또한 보기: lithium\template\view\Renderer::$_handlers
public applyHandler ( object $helper, string $method, string $name, mixed $value, array $options = [] ) : mixed
$helper object The instance of the object (usually a helper) that is invoking
$method string The object (helper) method which is applying the handler to the content
$name string The name of the value to which the handler is applied, i.e. `'url'`, `'path'` or `'title'`.
$value mixed The value to be transformed by the handler, which is ultimately returned.
$options array Any options which should be passed to the handler used in this call.
리턴 mixed The transformed value of `$value`, after it has been processed by a handler.

context() 공개 메소드

Returns either one or all context values for this rendering context. Context values persist across all templates rendered in the current context, and are usually outputted in a layout template.
또한 보기: lithium\template\view\Renderer::$_context
public context ( string $property = null ) : mixed
$property string If unspecified, an associative array of all context values is returned. If a string is specified, the context value matching the name given will be returned, or `null` if that name does not exist.
리턴 mixed A string or array, depending on whether `$property` is specified.

data() 공개 메소드

Returns all variables and their values that have been set.
public data ( ) : array
리턴 array Key/value pairs of data that has been set.

handlers() 공개 메소드

Gets or adds content handlers from/to this rendering context, depending on the value of $handlers. For more on how to implement handlers and the various types, see applyHandler().
또한 보기: lithium\template\view\Renderer::applyHandler()
또한 보기: lithium\template\view\Renderer::$_handlers
public handlers ( mixed $handlers = null ) : mixed
$handlers mixed If `$handlers` is empty or no value is provided, the current list of handlers is returned. If `$handlers` is a string, the handler with the name matching the string will be returned, or null if one does not exist. If `$handlers` is an array, the handlers named in the array will be merged into the list of handlers in this rendering context, with the pre-existing handlers taking precedence over those newly added.
리턴 mixed Returns an array of handlers or a single handler reference, depending on the value of `$handlers`.

helper() 공개 메소드

Brokers access to helpers attached to this rendering context, and loads helpers on-demand if they are not available.
public helper ( string $name, array $config = [] ) : object
$name string Helper name
$config array
리턴 object

render() 추상적인 공개 메소드

Render the template with given data. Abstract; must be added to subclasses.
abstract public render ( string $template, array | string $data = [], array $options = [] ) : string
$template string
$data array | string
$options array
리턴 string Returns the result of the rendered template.

request() 공개 메소드

Returns the Request object associated with this rendering context.
public request ( ) : object
리턴 object Returns an instance of `lithium\action\Request`, which provides the context for URLs, etc. which are generated in any templates rendered by this context.

respondsTo() 공개 메소드

Determines if a given method can be called.
public respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
리턴 boolean Returns `true` if the method can be called, `false` otherwise.

response() 공개 메소드

Returns the Response object associated with this rendering context.
public response ( ) : object
리턴 object Returns an instance of `lithium\action\Response`, which provides the i.e. the encoding for the document being the result of templates rendered by this context.

set() 공개 메소드

Allows variables to be set by one template and used in subsequent templates rendered using the same context. For example, a variable can be set in a template and used in an element rendered within a template, or an element or template could set a variable which would be made available in the layout.
public set ( array $data = [] ) : void
$data array An array of key/value pairs representing local variables that should be made available to all other templates rendered in this rendering context.
리턴 void

strings() 공개 메소드

Manages template strings.
public strings ( mixed $strings = null ) : mixed
$strings mixed
리턴 mixed

view() 공개 메소드

Retuns the View object that controls this rendering context's instance. This can be used, for example, to render view elements, i.e. view()->render('element' $name); ?>.
public view ( ) : object
리턴 object

프로퍼티 상세

$_autoConfig 보호되어 있는 프로퍼티

These configuration variables will automatically be assigned to their corresponding protected properties when the object is initialized.
protected array $_autoConfig
리턴 array

$_classes 보호되어 있는 프로퍼티

Renderer's dependencies. These classes are used by the output handlers to generate URLs for dynamic resources and static assets.
또한 보기: Renderer::$_handlers
protected array $_classes
리턴 array

$_context 보호되어 있는 프로퍼티

Context values that exist across all templates rendered in this context. These values are usually rendered in the layout template after all other values have rendered.
protected array $_context
리턴 array

$_data 보호되어 있는 프로퍼티

An array containing any additional variables to be injected into view templates. This allows local variables to be communicated between multiple templates (i.e. an element and a layout) which are using the same rendering context.
또한 보기: lithium\template\view\Renderer::set()
protected array $_data
리턴 array

$_handlers 보호되어 있는 프로퍼티

Automatically matches up template strings by name to output handlers. A handler can either be a string, which represents a method name of the helper, or it can be a closure or callable object. A handler takes 3 parameters: the value to be filtered, the name of the helper method that triggered the handler, and the array of options passed to the _render(). These handlers are shared among all helper objects, and are automatically triggered whenever a helper method renders a template string (using _render()) and a key which is to be embedded in the template string matches an array key of a corresponding handler.
또한 보기: lithium\template\view\Renderer::applyHandler()
또한 보기: lithium\template\view\Renderer::handlers()
protected array $_handlers
리턴 array

$_helpers 보호되어 있는 프로퍼티

Contains the list of helpers currently in use by this rendering context. Helpers are loaded via the helper() method, which is called by Renderer::__get(), allowing for on-demand loading of helpers.
protected array $_helpers
리턴 array

$_options 보호되어 있는 프로퍼티

Available options accepted by template\View::render(), used when rendering.
또한 보기: lithium\template\View::render()
protected array $_options
리턴 array

$_request 보호되어 있는 프로퍼티

The Request object instance, if applicable.
protected $_request

$_response 보호되어 있는 프로퍼티

The Response object instance, if applicable.
protected $_response

$_strings 보호되어 있는 프로퍼티

Aggregates named string templates used by helpers. Can be overridden to change the default strings a helper uses.
protected array $_strings
리턴 array

$_vars 보호되어 있는 프로퍼티

Variables that have been set from a view/element/layout/etc. that should be available to the same rendering context.
protected $_vars

$_view 보호되어 있는 프로퍼티

Holds an instance of the View object that created this rendering context. See the view() method for more details.
또한 보기: lithium\template\view\Renderer::view()
protected object $_view
리턴 object