getRoutes() public method

Get all routes registered on the adapter.
public getRoutes ( string $version = null ) : mixed
$version string
return mixed
Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }
Ejemplo n.º 3
0
 /**
  * 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));
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
 /**
  * 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);
         });
     }
 }
Ejemplo n.º 6
0
Archivo: Docs.php Proyecto: 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;
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
Ejemplo n.º 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();
 }