当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::getRoutes方法代码示例

本文整理汇总了PHP中Illuminate\Routing\Router::getRoutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getRoutes方法的具体用法?PHP Router::getRoutes怎么用?PHP Router::getRoutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Routing\Router的用法示例。


在下文中一共展示了Router::getRoutes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Prepare input
     $namespace = $this->getNamespace();
     $path = $this->getPath();
     // Prepare schema fields
     if (!$this->option('no-migration')) {
         $this->generateSchemaMigration();
     }
     // 2. Generate model
     $this->call('apigen:model', ['name' => $this->translator->translate($this->argument('name'))->toModelName(), '--path' => $path, '--namespace' => $namespace]);
     // 3. Generate repository
     $this->call('apigen:repository', ['name' => $this->translator->translate($this->argument('name'))->toModelName(), '--path' => $path, '--namespace' => $namespace]);
     // 4. Generate controller
     if (!$this->option('no-controller')) {
         $this->generateController();
     }
     // 5. Setup API route
     if (!$this->option('no-route') && !$this->option('no-controller')) {
         $resourceName = $this->translator->translate($this->argument('name'))->toTableName();
         $repositoryName = $this->translator->translate($this->argument('name'))->toRepositoryName();
         $routeBaseName = "api.{$resourceName}";
         if ($this->router->getRoutes()->hasNamedRoute("{$routeBaseName}.index")) {
             $this->error("Assuming routes for {$this->translator->translate($this->argument('name'))->toReadableName()} already exists.");
         } else {
             $this->info("Setting up route for '{$repositoryName}' ...");
             $routeString = "\n\nRoute::resource('{$resourceName}', '{$namespace}\\{$repositoryName}\\{$repositoryName}Controller', [ 'names' => [ " . "\n    'index' => '{$routeBaseName}.index', " . "\n    'create' => '{$routeBaseName}.create', " . "\n    'store' => '{$routeBaseName}.store', " . "\n    'show' => '{$routeBaseName}.show', " . "\n    'edit' => '{$routeBaseName}.edit', " . "\n    'update' => '{$routeBaseName}.update', " . "\n    'destroy' => '{$routeBaseName}.destroy', " . "\n] ]);";
             $this->filesystem->append(app_path() . '/routes.php', $routeString);
         }
     }
     // 6. Setup administration interface if needed
     if (!$this->option('no-admin')) {
         $this->setupAdministrationBackend();
     }
 }
开发者ID:lukaskorl,项目名称:apigen,代码行数:40,代码来源:GenerateResourceCommand.php

示例2: getRoutes

 /**
  * @return RouteCollection
  */
 public static function getRoutes()
 {
     if (is_null(self::$routes)) {
         self::$routes = self::$router->getRoutes();
     }
     return self::$routes;
 }
开发者ID:mohaiminul-sust,项目名称:laravel-apidocs,代码行数:10,代码来源:RouteResolver.php

示例3: getProtectedRouteList

 /**
  * Get route list protected by checkPermission middleware
  *
  * @return array
  */
 public function getProtectedRouteList()
 {
     if (is_null($this->protectedRouteList)) {
         $this->protectedRouteList = [];
         $routeList = $this->router->getRoutes();
         /** @var \Illuminate\Routing\Route $route */
         foreach ($routeList as $route) {
             // we need only routes which has permission checking middleware
             if (in_array('checkPermission', $route->middleware()) === false) {
                 continue;
             }
             if ($route->getActionName() == 'Closure') {
                 // permissions and closures doesn't work together
                 continue;
             }
             $routeName = $route->getName();
             if (empty($routeName)) {
                 // route name should not be empty
                 continue;
             }
             $this->protectedRouteList[$routeName] = ['route_action_name' => $route->getActionName(), 'route_name' => $routeName, 'controller_name' => $this->extractControllerName($route->getActionName()), 'controller_action_name' => $this->extractControllerActionName($route->getActionName())];
         }
     }
     return $this->protectedRouteList;
 }
开发者ID:aliukevicius,项目名称:laravel-rbac,代码行数:30,代码来源:PermissionService.php

示例4: getRoutes

 /**
  * Compile the routes into a displayable format.
  *
  * @return array
  */
 public function getRoutes()
 {
     $results = [];
     foreach ($this->router->getRoutes() as $route) {
         $results[] = $this->getRouteInformation($route);
     }
     return array_filter($results);
 }
开发者ID:laravel-jp-reference,项目名称:chapter8,代码行数:13,代码来源:RouteService.php

示例5: mergeExistingRoutes

 /**
  * Merge the existing routes with the new routes.
  *
  * @param \Illuminate\Routing\RouteCollection $routes
  *
  * @return \Illuminate\Routing\RouteCollection
  */
 protected function mergeExistingRoutes(RouteCollection $routes)
 {
     if (!isset($this->oldRoutes)) {
         $this->oldRoutes = $this->router->getRoutes();
     }
     foreach ($this->oldRoutes as $route) {
         $routes->add($route);
     }
     return $routes;
 }
开发者ID:riclt,项目名称:api,代码行数:17,代码来源:Laravel.php

示例6: getForPath

 /**
  * {@inheritdoc}
  */
 public function getForPath($path)
 {
     /** @var Request $request */
     $request = Request::create($path);
     try {
         $collectionMatcher = new RouteCollectionMatcher($this->router->getRoutes());
         if ($route = $collectionMatcher->getRouteForRequest($request)) {
             return $this->extractPermissionFrom($route);
         }
     } catch (HttpException $e) {
     }
     return null;
 }
开发者ID:digbang,项目名称:security,代码行数:16,代码来源:RoutePermissionRepository.php

示例7: getData

 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     $this->router = app('router');
     $this->url = app('url');
     $data = array('currentRoute' => $this->router->current());
     $routes = $this->router->getRoutes();
     $results = array();
     foreach ($routes as $name => $route) {
         $results[] = $this->getRouteInformation($route, $data['currentRoute']);
     }
     $data['routes'] = $results;
     return array('router' => $data);
 }
开发者ID:onigoetz,项目名称:profiler,代码行数:16,代码来源:Router41DataCollector.php

示例8: mergeOldRoutes

 /**
  * Merge the old application routes with the API routes.
  *
  * @param string $version
  *
  * @return array
  */
 protected function mergeOldRoutes($version)
 {
     if (!isset($this->oldRoutes)) {
         $this->oldRoutes = $this->router->getRoutes();
     }
     if (!isset($this->mergedRoutes[$version])) {
         $this->mergedRoutes[$version] = $this->routes[$version];
         foreach ($this->oldRoutes as $route) {
             $this->mergedRoutes[$version]->add($route);
         }
     }
     return $this->mergedRoutes[$version];
 }
开发者ID:JamesGuthrie,项目名称:api,代码行数:20,代码来源:Laravel.php

示例9: excludedRouteNames

 protected function excludedRouteNames($request)
 {
     $routes = $this->router->getRoutes();
     foreach ($this->excludedRouteNames as $name) {
         if ($routes->hasNamedRoute($name)) {
             $route = $routes->getByName($name);
             if ($route->matches($request)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:docit,项目名称:git-hook,代码行数:13,代码来源:VerifyCsrfToken.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = $this->router->getRoutes()->match($request);
     if ($route) {
         $subdomain = $route->parameter(config('tenant.subdomain'));
         $config = $this->tenantManager->getDatabaseConfig($subdomain);
         if ($config) {
             config()->set("database.connections.tenant", $config);
             $this->db->setDefaultConnection('tenant');
             $this->db->reconnect('tenant');
             return $next($request);
         }
     }
     abort(404);
 }
开发者ID:dlimars,项目名称:laravel-tenant-subdomain,代码行数:22,代码来源:TenantDatabase.php

示例11: last_page

 /**
  * @return string
  */
 public function last_page()
 {
     $lang = null;
     $collection = $this->router->getRoutes();
     $route = $collection->match(Request::create($this->wrappedObject->last_page));
     if ($route->getName() != null) {
         $langOptions = $this->getWioData($route->getName(), $route->parameters());
         if (!isset($langOptions['url'])) {
             $langOptions['url'] = route($route->getName(), $route->parameters());
         }
         if (!isset($langOptions['langString'])) {
             $langString = 'online.' . $route->getName();
         } else {
             $langString = 'online.' . $langOptions['langString'];
             unset($langOptions['langString']);
         }
         $lang = $this->translator->get($langString, $langOptions);
         // May happen if we have two routes 'xy.yx.zz' and 'xy.yx'
         if (is_array($lang)) {
             $lang = $this->translator->get($langString . '.index', $langOptions);
         }
     }
     if ($lang == null) {
         //			$lang = Lang::get('online.unknown', ['url' => '']);
         // Used for debugging, should be left here until we have added all routes
         $lang = 'online.' . $route->getName();
     }
     return $lang;
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:32,代码来源:User.php

示例12: __construct

 /**
  * Create a new route command instance.
  *
  * @param \Illuminate\Routing\Router $router
  * @param \Illuminate\Contracts\Config\Repository $config
  * @param \Illuminate\Filesystem\Filesystem $filesystem
  */
 public function __construct(Router $router, ConfigRepository $config, Filesystem $filesystem)
 {
     parent::__construct();
     $this->routes = $router->getRoutes();
     $this->config = $config->get('path2api');
     $this->filesystem = $filesystem;
 }
开发者ID:pomek,项目名称:path2api,代码行数:14,代码来源:GenerateDocsConsole.php

示例13: testResourceRoute

 public function testResourceRoute()
 {
     /* @var Dispatcher $dispatcher */
     $dispatcher = $this->getMock(Dispatcher::class);
     $router = new Router($dispatcher, null);
     $routeHelper = new RouteHelper($router);
     $routeHelper->resource('test', 'TestController')->get('get_test', 'get_test')->post('post_test', 'post_test')->put('put_test', 'put_test')->patch('patch_test', 'patch_test')->delete('delete_test', 'delete_test')->rawGet('rawget', 'rawget')->rawPost('rawpost', 'rawpost')->rawPut('rawput', 'rawput')->rawPatch('rawpatch', 'rawpatch')->rawDelete('rawdelete', 'rawdelete')->done();
     $routes = $router->getRoutes();
     $this->assertRoute($routes, 'test', 'GET', 'TestController@index');
     $this->assertRoute($routes, 'test?' . RouteHelper::PAGINATION_URI, 'GET', 'TestController@index');
     $this->assertRoute($routes, 'test', 'POST', 'TestController@store');
     $this->assertRoute($routes, 'test/{test}', 'GET', 'TestController@show');
     $this->assertRoute($routes, 'test/{test}', 'PUT', 'TestController@update');
     $this->assertRoute($routes, 'test/{test}', 'PATCH', 'TestController@update');
     $this->assertRoute($routes, 'test/{test}', 'DELETE', 'TestController@destroy');
     $this->assertRoute($routes, 'test/{test}/get_test', 'GET', 'TestController@get_test');
     $this->assertRoute($routes, 'test/{test}/post_test', 'POST', 'TestController@post_test');
     $this->assertRoute($routes, 'test/{test}/put_test', 'PUT', 'TestController@put_test');
     $this->assertRoute($routes, 'test/{test}/patch_test', 'PATCH', 'TestController@patch_test');
     $this->assertRoute($routes, 'test/{test}/delete_test', 'DELETE', 'TestController@delete_test');
     $this->assertRoute($routes, 'test/rawget', 'GET', 'TestController@rawget');
     $this->assertRoute($routes, 'test/rawpost', 'POST', 'TestController@rawpost');
     $this->assertRoute($routes, 'test/rawput', 'PUT', 'TestController@rawput');
     $this->assertRoute($routes, 'test/rawpatch', 'PATCH', 'TestController@rawpatch');
     $this->assertRoute($routes, 'test/rawdelete', 'DELETE', 'TestController@rawdelete');
 }
开发者ID:jarischaefer,项目名称:hal-api,代码行数:26,代码来源:ResourceRouteTest.php

示例14: __construct

 public function __construct(Arr $arr, Request $request, Router $router)
 {
     $this->arr = $arr;
     $this->request = $request;
     $this->user = $request->user();
     $this->router = $router;
     $this->routes = $router->getRoutes();
 }
开发者ID:nicegal17,项目名称:Accounting-System,代码行数:8,代码来源:Builder.php

示例15: __construct

 public function __construct(Router $router, Filesystem $filesystem, $appUrl, $savePath, $saveName)
 {
     parent::__construct();
     $this->routes = $router->getRoutes();
     $this->filesystem = $filesystem;
     $this->appUrl = $appUrl;
     $this->filePath = $savePath . '/' . $saveName . '.html';
 }
开发者ID:herlevsen,项目名称:laravel-route-bookmarker,代码行数:8,代码来源:RouteBookmarkerCommand.php


注:本文中的Illuminate\Routing\Router::getRoutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。