lithium\net\http\Media::_handle PHP Method

_handle() protected static method

Called by Media::render() to render response content. Given a content handler and data, calls the content handler and passes in the data, receiving back a rendered content string.
See also: lithium\action\Response
protected static _handle ( array $handler, array $data, object &$response ) : string
$handler array
$data array
$response object A reference to the `Response` object for this dispatch cycle.
return string
    protected static function _handle($handler, $data, &$response)
    {
        $params = array('response' => &$response) + compact('handler', 'data');
        return static::_filter(__FUNCTION__, $params, function ($self, $params) {
            $response = $params['response'];
            $handler = $params['handler'];
            $data = $params['data'];
            $options = $handler;
            if (isset($options['request'])) {
                $options += $options['request']->params;
                unset($options['request']);
            }
            switch (true) {
                case $handler['encode']:
                    return $self::encode($handler, $data, $response);
                case $handler['template'] === false && is_string($data):
                    return $data;
                case $handler['view']:
                    unset($options['view']);
                    $instance = $self::view($handler, $data, $response, $options);
                    return $instance->render('all', (array) $data, $options);
                default:
                    throw new MediaException("Could not interpret type settings for handler.");
            }
        });
    }