lithium\net\http\Media::handlers()

public static method

Helper method for listing registered type handlers. Returns all handlers, or the handler for a specific media type, if requested.

Parameters

  • string $type

    The type of handler to return.

Returns

mixed

Array of all handlers, or the handler for a specific type.

Source

	public static function handlers($type = null) {
		$handlers = static::$_handlers + [
			'default' => [
				'view'     => 'lithium\template\View',
				'encode'   => false,
				'decode'   => false,
				'cast'     => false,
				'paths'    => [
					'template' => '{:library}/views/{:controller}/{:template}.{:type}.php',
					'layout'   => '{:library}/views/layouts/{:layout}.{:type}.php',
					'element'  => '{:library}/views/elements/{:template}.{:type}.php'
				]
			],
			'html' => [],
			'json' => [
				'cast' => true,
				'encode' => 'json_encode',
				'decode' => function($data) {
					return json_decode($data, true);
				}
			],
			'text' => ['cast' => false, 'encode' => function($s) { return $s; }],
			'form' => [
				'cast' => true,
				'encode' => 'http_build_query',
				'decode' => function($data) {
					$decoded = [];
					parse_str($data, $decoded);
					return $decoded;
				}
			]
		];

		if ($type) {
			return isset($handlers[$type]) ? $handlers[$type] : null;
		}
		return $handlers;
	}