本文整理汇总了PHP中Illuminate\Routing\Router::match方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::match方法的具体用法?PHP Router::match怎么用?PHP Router::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Router
的用法示例。
在下文中一共展示了Router::match方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerRoutes
/**
* Register routes from an array
*
* @param array $data
*
* @return void
*/
protected function registerRoutes(array $data)
{
foreach ($data as $method => $routes) {
if (in_array($method, $this->verbs)) {
foreach ($routes as $uri => $action) {
$this->router->match(array($method), $uri, $action);
}
}
}
}
示例2: let
function let(Repository $config, Filesystem $fs, OutputInterface $output)
{
$config_file = (include __DIR__ . '/../../src/config/path2api.php');
$this->tempFile = $config_file['file'];
$config->get('path2api')->willReturn($config_file);
$router = new Router(new Dispatcher());
$router->get('/api', ['uses' => 'Stubs\\Pomek\\Path2API\\Controller@homepage']);
$router->post('/api/contact/{email}', ['uses' => 'Stubs\\Pomek\\Path2API\\Controller@contact']);
$router->match(['GET', 'POST'], '/api/test/{id}', function ($id) {
return $id;
});
$this->beConstructedWith($router, $config, $fs);
$this->setOutput($output);
}
示例3: makeAndRegisterRoute
/**
* Make route from route data and register it into router
*
* @param array $route_data
* @param string $controller
* @return Illuminate\Routing\Route
*/
protected function makeAndRegisterRoute($controller, ReflectionMethod $method, array $route_data)
{
$uses = $controller . '@' . $method->getName();
$methods = $route_data['methods'];
$uri = $route_data['uri'];
$action = ['uses' => $uses];
if (!empty($route_data['middleware'])) {
$action['middleware'] = $route_data['middleware'];
}
if (!empty($route_data['name'])) {
$action['as'] = $route_data['name'];
}
$route = $this->router->match($methods, $uri, $action);
foreach ($route_data['conditions'] as $param => $regex) {
$route->where($param, $regex);
}
// Laravel Route doesn't provide method for get route conditions,
// so we need to declare new attribute for generating(transforming) purpose
$route->conditions = $route_data['conditions'];
$route->description = $route_data['description'];
return $route;
}
示例4: match
/**
* Register a new route with the given verbs.
*
* @param array|string $methods
* @param string $uri
* @param \Closure|array|string $action
* @return \Illuminate\Routing\Route
* @static
*/
public static function match($methods, $uri, $action)
{
return \Illuminate\Routing\Router::match($methods, $uri, $action);
}
示例5: match
/**
* Register a new route with the given verbs.
*
* @param array|string $methods
* @param string $uri
* @param \Closure|array|string $action
*
* @return \Illuminate\Routing\Route|void
*/
public function match($methods, $uri, $action)
{
return $this->router->match($methods, $uri, $action);
}
示例6: inject
/**
* Inject routes into the provided router.
*
* @param Router $router
* @return Router
*/
public function inject(Router $router)
{
$router->group(Arr::filterNullValues(['middleware' => $this->middleware, 'prefix' => $this->prefix]), function (Router $router) {
Std::each(function (ResourceMethod $method) use($router) {
$handler = vsprintf('%s@%s', [$this->controller, $method->getMethod()]);
$router->match([$method->getVerb()], $method->getPath(), $handler);
}, $this->methods);
});
return $router;
}
示例7: addResourceUpdate
/**
* Add the update method for a resourceful route.
*
* @param string $name
* @param string $base
* @param string $controller
* @param array $options
* @return void
*/
protected function addResourceUpdate($name, $base, $controller, $options)
{
$uri = $this->getResourceUri($name) . '/{' . $base . '}';
$action = $this->getResourceAction($name, $controller, 'update', $options);
return $this->router->match(['PUT', 'PATCH'], $uri, $action);
}
示例8: match
/**
* Register a new route with the given verbs.
*
* @param array|string $methods
* @param string $uri
* @param \Closure|array|string|null $action
* @return \Illuminate\Routing\Route
*/
public function match($methods, $uri, $action = null)
{
return $this->router->match($methods, $uri, $this->compileAction($action));
}
示例9: addSymfonyRoutes
/**
* Expose symfonys routes to Laravel.
*
* @param Router $router
*/
public function addSymfonyRoutes(Router $router)
{
foreach ($this->routesFromSymfony as $route) {
$router->match($route['methods'], $route['path'], $route['action']);
}
}