lithium\template\view\Renderer::applyHandler PHP Method

applyHandler() public method

- 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.
See also: lithium\template\view\Renderer::handlers()
See also: 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.
return mixed The transformed value of `$value`, after it has been processed by a handler.
    public function applyHandler($helper, $method, $name, $value, array $options = array())
    {
        if (!(isset($this->_handlers[$name]) && ($handler = $this->_handlers[$name]))) {
            return $value;
        }
        switch (true) {
            case is_string($handler) && !$helper:
                $helper = $this->helper('html');
            case is_string($handler) && is_object($helper):
                return $helper->invokeMethod($handler, array($value, $method, $options));
            case is_array($handler) && is_object($handler[0]):
                list($object, $func) = $handler;
                return $object->invokeMethod($func, array($value, $method, $options));
            case is_callable($handler):
                return $handler($value, array($helper, $method), $options);
            default:
                return $value;
        }
    }