/** * @expectedException Packfire\Router\Exceptions\MissingRequiredParameterException */ public function testGenerateFailRequiredParam() { $route = new BaseRoute('test', array('path' => '/test/example/:id(.:format?)', 'params' => array('id' => 'i'))); $generator = new Generator(); $generator->generate($route, array('format' => 'json')); }
/** * Generate a URL for a route with its parameters * @param string $name Name of the route in the router to generate * @param array $params (optional) The optional parameters to enter into the URL * @return string Returns the generated URL of the route and its parameters */ public function generate($name, $params = array()) { if (isset($this->routes[$name])) { if (isset($this->container['Packfire\\Router\\GeneratorInterface'])) { $generator = $this->container['Packfire\\Router\\GeneratorInterface']; } else { $generator = new Generator(); } return $generator->generate($this->routes[$name], $params); } else { throw new RouteNotFoundException($name); } }