lithium\action\Response::type PHP Метод

type() публичный Метод

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'`
Результат 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 === null && $this->_type === null) {
            $type = 'html';
        }
        return parent::type($type);
    }

Usage Example

Пример #1
0
 /**
  * Tests that attempts to render a media type with no handler registered produces an
  * 'unhandled media type' exception, even if the type itself is a registered content type.
  *
  * @return void
  */
 public function testUnregisteredContentHandler()
 {
     $response = new Response();
     $response->type('xml');
     $this->expectException("Unhandled media type `xml`.");
     Media::render($response, array('foo' => 'bar'));
     $result = $response->body;
     $this->assertNull($result);
 }
All Usage Examples Of lithium\action\Response::type