Example #1
0
 /**
  * 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 boolean $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 self::$_validExtensions;
     }
     if (!$merge) {
         return self::$_validExtensions = $extensions;
     }
     return self::$_validExtensions = array_merge(self::$_validExtensions, $extensions);
 }
Example #2
0
 /**
  * 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['url']['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.
  *
  * A list of valid extension can be passed to this method, i.e. Router::parseExtensions('rss', 'xml');
  * If no parameters are given, anything after the first . (dot) after the last / in the URL will be
  * parsed, excluding querystring parameters (i.e. ?q=...).
  *
  * @return void
  */
 public static function parseExtensions()
 {
     self::$_parseExtensions = true;
     if (func_num_args() > 0) {
         self::$_validExtensions = func_get_args();
     }
 }