Router::setExtensions PHP Method

setExtensions() public static method

To have the extensions parsed you still need to call Router::parseExtensions()
public static setExtensions ( array $extensions, boolean $merge = true ) : array
$extensions array List of extensions to be added as valid extension
$merge boolean Default true will merge extensions. Set to false to override current extensions
return array
    public static function setExtensions($extensions, $merge = true)
    {
        if (!is_array($extensions)) {
            return static::$_validExtensions;
        }
        if (!$merge) {
            return static::$_validExtensions = $extensions;
        }
        return static::$_validExtensions = array_merge(static::$_validExtensions, $extensions);
    }

Usage Example

 /**
  * Test that ext is set to the first listed extension with multiple accepted
  * content types.
  * Having multiple types accepted with same weight, means the client lets the
  * server choose the returned content type.
  *
  * @return void
  */
 public function testInitializeNoContentTypeWithMultipleAcceptedTypes()
 {
     $_SERVER['HTTP_ACCEPT'] = 'application/json, application/javascript, application/xml, */*; q=0.01';
     $this->assertNull($this->RequestHandler->ext);
     Router::parseExtensions('xml', 'json');
     $this->RequestHandler->initialize($this->Controller);
     $this->assertEquals('xml', $this->RequestHandler->ext);
     $this->RequestHandler->ext = null;
     Router::setExtensions(array('json', 'xml'), false);
     $this->RequestHandler->initialize($this->Controller);
     $this->assertEquals('json', $this->RequestHandler->ext);
 }
All Usage Examples Of Router::setExtensions