lithium\action\Request::type PHP Method

type() public method

Sets/Gets the content type. If 'type' is null, the method will attempt to determine the type from the params, then from the environment setting
public type ( string $type = null ) : string
$type string a full content type i.e. `'application/json'` or simple name `'json'`
return string A simple content type name, i.e. `'html'`, `'xml'`, `'json'`, etc., depending on the content type of the request.
    public function type($type = null)
    {
        if (!$type && !empty($this->params['type'])) {
            $type = $this->params['type'];
        }
        return parent::type($type);
    }

Usage Example

Example #1
0
 public function testRequestTypeFromHeader()
 {
     $request = new Request(array('env' => array('CONTENT_TYPE' => 'json')));
     $this->assertEqual('json', $request->type());
 }
All Usage Examples Of lithium\action\Request::type