lithium\net\http\Media::_handle()
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.
Parameters
-
array
$handler
-
array
$data
-
object
$response
A reference to the
Response
object for this dispatch cycle.
Returns
stringFilter
This method can be filtered.
Source
protected static function _handle($handler, $data, &$response) {
$params = ['response' => &$response] + compact('handler', 'data');
return Filters::run(get_called_class(), __FUNCTION__, $params, function($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 static::encode($handler, $data, $response);
case ($handler['template'] === false) && is_string($data):
return $data;
case $handler['view']:
unset($options['view']);
$instance = static::view($handler, $data, $response, $options);
return $instance->render('all', (array) $data, $options);
default:
throw new MediaException("Could not interpret type settings for handler.");
}
});
}