lithium\net\http\Media::types PHP Method

types() public static method

Returns the list of registered media types. New types can be set with the type() method.
public static types ( ) : array
return array Returns an array of media type extensions or short-names, which comprise the list of types handled.
    public static function types()
    {
        return array_keys(static::_types());
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Tests setting, getting and removing custom media types.
  *
  * @return void
  */
 public function testMediaTypes()
 {
     $result = Media::types();
     $this->assertTrue(is_array($result));
     $this->assertTrue(in_array('json', $result));
     $this->assertFalse(in_array('my', $result));
     $this->assertEqual($result, Media::formats());
     $result = Media::type('json');
     $expected = 'application/json';
     $this->assertEqual($expected, $result['content']);
     $expected = array('view' => false, 'layout' => false, 'encode' => 'json_encode', 'decode' => 'json_decode');
     $this->assertEqual($expected, $result['options']);
     Media::type('my', 'text/x-my', array('view' => '\\my\\custom\\View', 'layout' => false));
     $result = Media::types();
     $this->assertTrue(in_array('my', $result));
     $result = Media::type('my');
     $expected = 'text/x-my';
     $this->assertEqual($expected, $result['content']);
     $expected = array('view' => '\\my\\custom\\View', 'template' => null, 'layout' => null, 'encode' => null, 'decode' => null);
     $this->assertEqual($expected, $result['options']);
     Media::type('my', false);
     $result = Media::types();
     $this->assertFalse(in_array('my', $result));
 }
All Usage Examples Of lithium\net\http\Media::types