Example #1
0
 public function path($routeName, $options = null)
 {
     $route = $this->router->getRouteName($routeName);
     if ($route != null) {
         $url = $route['pattern'];
         if ($options != null && is_array($options)) {
             $first = true;
             foreach ($options as $name => $value) {
                 if (is_string($value)) {
                     if ($first) {
                         $url .= '?';
                         $first = false;
                     } else {
                         $url .= '&';
                     }
                     $url .= "{$name}={$value}";
                 }
             }
         }
         return $url;
     } else {
         throw new Twig_Error_Runtime('There\'s no route with this name');
     }
 }