lithium\net\http\Media::_types()
Helper method for listing registered media types. Returns all types, or a single content type if a specific type is specified.
Parameters
-
string
$type
Type to return.
Returns
mixedArray of types, or single type requested.
Source
protected static function _types($type = null) {
$types = static::$_types + array(
'html' => array('text/html', 'application/xhtml+xml', '*/*'),
'htm' => array('alias' => 'html'),
'form' => array('application/x-www-form-urlencoded', 'multipart/form-data'),
'json' => array('application/json'),
'rss' => array('application/rss+xml'),
'atom' => array('application/atom+xml'),
'css' => array('text/css'),
'js' => array('application/javascript', 'text/javascript'),
'text' => array('text/plain'),
'txt' => array('alias' => 'text'),
'xml' => array('application/xml', 'application/soap+xml', 'text/xml')
);
if (!$type) {
return $types;
}
if (strpos($type, '/') === false) {
return isset($types[$type]) ? $types[$type] : null;
}
if (strpos($type, ';')) {
list($type) = explode(';', $type, 2);
}
$result = array();
foreach ($types as $name => $cTypes) {
if ($type === $cTypes || (is_array($cTypes) && in_array($type, $cTypes))) {
$result[] = $name;
}
}
if (count($result) === 1) {
return reset($result);
}
return $result ?: null;
}