/** * Set/add valid extensions. * * To have the extensions parsed you still need to call `Router::parseExtensions()` * * @param array $extensions List of extensions to be added as valid extension * @param bool $merge 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); }
/** * Set/add valid extensions. Instructs the router to parse out file extensions * from the URL. For example, http://example.com/posts.rss would yield an file * extension of "rss". The file extension itself is made available in the * controller as `$this->params['_ext']`, and is used by the RequestHandler * component to automatically switch to alternate layouts and templates, and * load helpers corresponding to the given content, i.e. RssHelper. Switching * layouts and helpers requires that the chosen extension has a defined mime type * in `Cake\Network\Response`. * * An array of valid extension can be passed to this method. If called without * any parameters it will return current list of set extensions. * * @param array|string $extensions List of extensions to be added as valid extension * @param bool $merge Default true will merge extensions. Set to false to override * current extensions * @return array */ public static function parseExtensions($extensions = null, $merge = true) { if ($extensions === null) { return static::$_validExtensions; } $extensions = (array) $extensions; if ($merge) { $extensions = array_merge(static::$_validExtensions, $extensions); } static::$_routes->parseExtensions($extensions); return static::$_validExtensions = $extensions; }