getRoutes() public method

Get all routes registered on the adapter.
public getRoutes ( string $version = null ) : mixed
$version string
return mixed
コード例 #1
0
ファイル: Docs.php プロジェクト: khlipeng/api
 /**
  * Get all the controller instances.
  *
  * @return array
  */
 protected function getControllers()
 {
     $controllers = new Collection();
     foreach ($this->router->getRoutes() as $collections) {
         foreach ($collections as $route) {
             if ($controller = $route->getController()) {
                 $controllers[] = $controller;
             }
         }
     }
     return $controllers;
 }
コード例 #2
0
ファイル: Routes.php プロジェクト: lengdelong/api
 /**
  * Create a new routes command instance.
  *
  * @param \Dingo\Api\Routing\Router $router
  *
  * @return void
  */
 public function __construct(Router $router)
 {
     // Ugly, but we need to bypass the constructor and directly target the
     // constructor on the command class.
     Command::__construct();
     $this->routes = $router->getRoutes();
 }
コード例 #3
0
ファイル: Routes.php プロジェクト: sharenjoy/api
 /**
  * Compile the routes into a displayable format.
  *
  * @return array
  */
 protected function getRoutes()
 {
     $routes = [];
     foreach ($this->router->getRoutes() as $collection) {
         foreach ($collection->getRoutes() as $route) {
             $routes[] = $this->filterRoute(['host' => $route->domain(), 'uri' => implode('|', $route->methods()) . ' ' . $route->uri(), 'name' => $route->getName(), 'action' => $route->getActionName(), 'protected' => $route->isProtected() ? 'Yes' : 'No', 'versions' => implode(', ', $route->versions()), 'scopes' => implode(', ', $route->scopes()), 'rate' => $this->routeRateLimit($route)]);
         }
     }
     if ($sort = $this->option('sort')) {
         $routes = Arr::sort($routes, function ($value) use($sort) {
             return $value[$sort];
         });
     }
     if ($this->option('reverse')) {
         $routes = array_reverse($routes);
     }
     return array_filter(array_unique($routes, SORT_REGULAR));
 }
コード例 #4
0
ファイル: Docs.php プロジェクト: lengdelong/api
 /**
  * Get all the controller instances.
  *
  * @return array
  */
 protected function getControllers()
 {
     $controllers = new Collection();
     foreach ($this->router->getRoutes() as $collections) {
         foreach ($collections as $route) {
             if ($controller = $route->getController()) {
                 $this->addControllerIfNotExists($controllers, $controller);
             }
         }
     }
     return $controllers;
 }
コード例 #5
0
 /**
  * Merge routes defined by packages into API router.
  *
  * @param  \Dingo\Api\Routing\Router  $api
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 protected function mergePackgeRoutes(ApiRouter &$api, Router $router)
 {
     foreach ($router->getRoutes() as $route) {
         $api->version(array_keys($api->getRoutes()), function ($api) use($route) {
             $action = $route->getAction();
             // Remove prefix if present
             if (isset($action['prefix'])) {
                 unset($action['prefix']);
             }
             $api->addRoute($route->getMethods(), $route->uri(), $action);
         });
     }
 }
コード例 #6
0
ファイル: Docs.php プロジェクト: rit-sse/api
 /**
  * Get all the controller instances.
  *
  * @return array
  */
 protected function getControllers()
 {
     $controllers = [];
     foreach ($this->router->getRoutes() as $route) {
         $actionName = $route->getActionName();
         if (!empty($actionName) && $actionName !== 'Closure') {
             $segments = explode('@', $actionName);
             $controllers[] = $segments[0];
         }
     }
     $controllerCollection = new Collection(array_unique($controllers));
     return $controllerCollection;
 }
コード例 #7
0
ファイル: Docs.php プロジェクト: vanbrabantf/api
 /**
  * Get all the controller instances.
  *
  * @return array
  */
 protected function getControllers()
 {
     $controllers = new Collection();
     foreach ($this->router->getRoutes() as $collections) {
         foreach ($collections as $route) {
             if ($controller = $route->getController()) {
                 if (!$controllers->has(get_class($controller))) {
                     $controllers->put(get_class($controller), $controller);
                 }
             }
         }
     }
     return $controllers;
 }
コード例 #8
0
 /**
  * Create a new route command instance.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function __construct(Router $router)
 {
     $this->storagePath = storage_path() . '/templates/apidocs';
     $this->router = $router;
     $this->routes = $router->getRoutes();
 }