Example #1
0
 /**
  * Add a new route to the configured list of routes
  */
 public function addRoute($params)
 {
     if (!empty($params['path'])) {
         $template = new Template($params['path']);
         if (!empty($params['handlers'])) {
             foreach ($params['handlers'] as $key => $pattern) {
                 $template->pattern($key, $pattern);
             }
         }
         $methods = array_intersect(self::$methods, array_keys($params));
         foreach ($methods as $method) {
             $this->routes[$method][$params['path']] = array('template' => $template, 'callback' => $params[$method], 'file' => !empty($params['file']) ? $params['file'] : '');
         }
     }
 }