getRoutes() public static method

Get the underlying route collection.
public static getRoutes ( ) : Illuminate\Routing\RouteCollection
return Illuminate\Routing\RouteCollection
 /**
  * Tests that the authorization method is attached to all routes except for the / and /home
  *
  */
 public function testAllRoutesHaveAuthorization()
 {
     $routesArr = Route::getRoutes();
     //get all routes
     foreach ($routesArr as $route) {
         $path = $route->getPath();
         // Log::info('testing route ' . $path);
         $vals = array_values($route->middleware());
         $found = false;
         foreach ($vals as $index => $el) {
             if (FALSE !== strpos($el, "auth")) {
                 $found = true;
                 break;
             }
         }
         /**
                     Temporary hack to handle resource routes until we finish the api
                      *
                      **/
         if (starts_with($route->getPath(), "api")) {
             $found = true;
         }
         if ('/' === $path || 'home' === $path || 'index.php' === $path || 'mainlogin' === $path || 'register' === $path || 'login' === $path || 'forgotpassword' === $path) {
             $this->assertFalse($found);
         } else {
             $this->assertTrue($found, 'Route: ' . $route->getPath() . ' doesn\'t have the Authorize middleware attached (keyword \'auth\' not found in middleware array)');
         }
     }
 }
 public function testIsInValidGenerateRoute()
 {
     $invalidRoute = 'generate';
     $routeCollection = Route::getRoutes();
     $isValidRoute = $this->generator->checkRouteIsValid($invalidRoute, $routeCollection);
     $this->assertFalse($isValidRoute);
 }
 /**
  * Print all available routes
  * http://localhost/debug/routes
  *
  * @return String
  */
 public function getRoutes()
 {
     $routeCollection = Route::getRoutes();
     foreach ($routeCollection as $value) {
         echo "<a href='/" . $value->getPath() . "' target='_blank'>" . $value->getPath() . "</a><br>";
     }
 }
Example #4
0
 public static function returnRoute($data)
 {
     if (!isset(Route::getRoutes()[$data[0]])) {
         return App::getBase();
     }
     $route = Route::getRoutes()[$data[0]];
     $data = array_slice($data, 1);
     if (!$route['rules']) {
         $url = $route['url'];
         return App::getBase() . implode('/', $url);
     } else {
         $url = [];
         foreach ($route['rules'] as $int => $rule) {
             if (!isset($data[$int])) {
                 continue;
             }
             $rule = $route['url'][$int + 1];
             $match = $route['rules'][$int];
             if ($rule == '(.*)') {
                 if (!preg_match("/({$match})/", $data[$int])) {
                     continue;
                 }
                 $url[] = $data[$int];
             } else {
                 $url[] = $data[$int];
             }
         }
         if (count($url)) {
             array_unshift($url, $route['url'][0]);
             $url = implode('/', $url);
             return App::getBase() . $url;
         }
     }
     return App::getBase();
 }
 public function GET_createGroupForm()
 {
     $theme = Theme::uses('notebook')->layout('main');
     $theme->setMenu('user.group');
     $routeCollection = Route::getRoutes();
     $params = array('routes' => $routeCollection);
     return $theme->scope('user.group-create', $params)->render();
 }
 protected function getAllExisting()
 {
     try {
         return Route::getRoutes($this->agency, TableUpdate::getLiveVersion());
     } catch (Exception $ex) {
         return false;
     }
 }
Example #7
0
 public function __construct()
 {
     foreach (\Route::getRoutes() as $route) {
         $action = is_string($route->getAction()['uses']) ? $route->getAction()['uses'] : 'Closure';
         $name = isset($route->getAction()['as']) ? $route->getAction()['as'] : '';
         $this->routes[] = ['method' => implode('|', $route->getMethods()), 'name' => $name, 'action' => $action, 'uri' => $route->getUri(), 'middleware' => isset($route->getAction()['middleware']) && is_array($route->getAction()['middleware']) ? implode(',', $route->getAction()['middleware']) : (isset($route->getAction()['middleware']) ? $route->getAction()['middleware'] : '')];
     }
 }
/**
 * Generate a HTML link to a named route.
 *
 * @param  string  $name
 * @param  string  $title
 * @param  array   $parameters
 * @param  array   $attributes
 * @return string
 */
function link_to_route($name, $title = null, $parameters = array(), $attributes = array())
{
    if (Route::getRoutes()->hasNamedRoute($name)) {
        return app('html')->linkRoute($name, $title, $parameters, $attributes);
    } else {
        return '<a href="javascript:void(0)"' . HTML::attributes($attributes) . '>' . $name . '</a>';
    }
}
Example #9
0
 /**
  * Testing all routes
  *
  * @return void
  */
 public function testAllDisplayPages()
 {
     $user = User::find(2);
     $results = [];
     foreach (Route::getRoutes() as $route) {
         $this->actingAs($user)->withSession(['foo' => 'bar'])->visit($route->uri());
         //$response = $this->call('GET', $route->uri());
         //$this->assertEquals(200, $response->getStatusCode(), $route->uri() . " " . $response);
     }
 }
 public function getSlugsInvalid()
 {
     $list = array();
     foreach (\Route::getRoutes() as $route) {
         $temp = explode('/', $route->getPath());
         if (trim($temp[0])) {
             $list[] = $temp[0];
         }
     }
     return array_unique($list);
 }
Example #11
0
 /**
  * Get all the installer steps
  *
  * @return array
  */
 function steps()
 {
     $steps = [];
     foreach (Route::getRoutes() as $route) {
         $route_name = $route->getName();
         if (str_contains($route_name, 'admin.installer')) {
             $steps[] = $route_name;
         }
     }
     return $steps;
 }
 /**
  * returns all registered route action name
  *
  * @return array
  */
 public function getRouteActions()
 {
     $return = [];
     foreach (\Route::getRoutes() as $route) {
         $actionNameExplode = explode("\\", $route->getActionName());
         end($actionNameExplode);
         $actionName = $actionNameExplode[key($actionNameExplode)];
         $return[] = $actionName;
     }
     return $return;
 }
Example #13
0
 public static function getRoutes()
 {
     $routeCollection = \Route::getRoutes();
     foreach ($routeCollection as $value) {
         if ($value->getActionName() != "Closure") {
             $data['data']['method'][] = $value->getMethods()[0];
             $data['data']['path'][] = $value->getPath();
             $data['data']['action'][] = $value->getActionName();
         }
     }
     return $data;
 }
Example #14
0
 /**
  * @return mixed get the data to be serialized
  */
 public function getData()
 {
     $data = array('currentRoute' => \Route::getCurrentRoute());
     $base_path = Request::root();
     $routes = \Route::getRoutes()->all();
     $results = array();
     foreach ($routes as $name => $route) {
         $results[] = $this->getRouteInformation($name, $route, $data['currentRoute'], $base_path);
     }
     $data['routes'] = $results;
     return array('router' => $data);
 }
Example #15
0
 private function createForm()
 {
     $this->addPanel('Dados do grupo de usuário', function ($panel) {
         $panel->addText('name', 'Nome do grupo');
         $panel->addCheckboxActive('status', 'Status')->width = 6;
         $panel->addCheckbox('super_administrator', 'Super Administrador')->width = 6;
     });
     $this->addPanel('Descrição do grupo', function ($panel) {
         $panel->addTextArea('description', 'Descrição')->addAttribute('style', 'height: 118px;');
     });
     $this->addPanel('Permissões de acesso', function ($panel) {
         $permissions = [];
         $ignore_routes = config('bw.middleware.aclroutes.ignore_routes', []);
         foreach (\Route::getRoutes() as $route) {
             if ($route->getName()) {
                 if (!in_array($route->getName(), $ignore_routes)) {
                     $name = 'route::' . $route->getName();
                     if (isset($route->getAction()['middleware'])) {
                         if (in_array('bw.aclroutes', $route->getAction()['middleware'])) {
                             $url = str_replace('.', '/', str_replace('route::bw.', '/', $name));
                             $permissions[$name] = ['label' => $url, 'value' => $name, 'checked' => ''];
                         }
                     }
                 }
             }
         }
         //
         if (count(old())) {
             foreach (old('permissions', []) as $i) {
                 $permissions[$i]['checked'] = 'checked';
             }
         } else {
             if ($this->model) {
                 $erros = [];
                 foreach ($this->model->permissions as $i) {
                     if (isset($permissions[$i->permission])) {
                         $permissions[$i->permission]['checked'] = 'checked';
                     } else {
                         $erros[] = '- ' . $i->permission;
                     }
                 }
                 if (count($erros)) {
                     $msg = 'As seguinte permissões não existem mais e serão removidas ao salvar o grupo<br><br>' . join('<br>', $erros);
                     app('flash')->warning($msg);
                 }
             }
         }
         //
         $panel->width = 12;
         $panel->addIncludeFile('BW::users.groups.permissions', $permissions);
     });
     return $this;
 }
Example #16
0
 /**
  * @param string $controller
  * @return array
  */
 public function getMethodsByController($controller)
 {
     $methods = array('GET');
     foreach (\Route::getRoutes() as $route) {
         if (!in_array('GET', $route->methods())) {
             $action = $route->getAction();
             if ($this->getControllerNameByAction($action['controller']) == $controller) {
                 $methods = array_merge($methods, $route->methods());
             }
         }
     }
     return $methods;
 }
 /**
  * run
  *
  * @access public
  * @return void
  */
 public function run()
 {
     parent::run();
     $routes = Route::getRoutes();
     $children = [];
     foreach ($routes as $route) {
         list($controller, $action) = explode('@', $route->getActionName());
         $parent = Resource::firstOrCreate(['name' => $controller]);
         $child = ['name' => $route->getName(), 'action' => $action, 'url' => $route->getPath(), 'parent_id' => $parent->id];
         $children[] = $child;
     }
     DB::table('resources')->insert($children);
 }
Example #18
0
 public function testGetAllRoutes()
 {
     $this->withoutMiddleware();
     $res = $this->call('GET', '/routes');
     $this->assertEquals(200, $res->getStatusCode());
     $result = json_decode($res->getContent());
     $routes = R::getRoutes();
     foreach ($routes as $key => $route) {
         $method = is_array($method = $route->getMethods()) ? $method[0] : $method;
         $name = $route->getPath() === '/' ? $route->getPath() : '/' . $route->getPath();
         $this->assertEquals($method, $result->entities[$key]->route_method);
         $this->assertEquals($name, $result->entities[$key]->route_name);
     }
 }
 protected function initRoutes()
 {
     if (!Cache::get('routes') || !Cache::get('routes_simple')) {
         $route_collection = Route::getRoutes();
         foreach ($route_collection as $route) {
             if ($route->getName() && $route->getPrefix()) {
                 $group = explode('@', $route->getActionName());
                 $routes[$route->getPrefix()][$group[0]][$route->getName()] = $route->getName();
                 $routes_simple[] = $route->getName();
             }
         }
         Cache::forever('routes', $routes);
         Cache::forever('routes_simple', $routes_simple);
     }
 }
function generateXMLFile(Agency $agencyObj)
{
    $dbObj = DBPool::getInstance();
    $routeArray = Route::getRoutes($agencyObj);
    $stopArray = Stop::getStops($agencyObj);
    $xmlStr = '<?xml version="1.0" encoding="UTF-8" ?><agency title="' . $agencyObj->getTitle() . '" shortTitle="' . $agencyObj->getShortTitle() . '"></agency>';
    $xml = new SimpleXMLElement($xmlStr);
    foreach ($stopArray as $s) {
        $stop = $xml->addChild("stop");
        $stop->addAttribute("tag", $s->getTag());
        $stop->addAttribute("title", $s->getPrettyTitle());
        $stop->addAttribute("lat", $s->getLatitude());
        $stop->addAttribute("lon", $s->getLongitude());
        $stop->addAttribute("oppositeStopTag", $s->getFlipStopTag());
    }
    foreach ($routeArray as $r) {
        $route = $xml->addChild("route");
        $route->addAttribute("tag", $r->getTag());
        $route->addAttribute("title", $r->getTitle());
        $route->addAttribute("shortTitle", $r->getShortTitle());
        $route->addAttribute("color", $r->getColor());
        $route->addAttribute("latMin", $r->getLatMin());
        $route->addAttribute("latMax", $r->getLatMax());
        $route->addAttribute("lonMin", $r->getLonMin());
        $route->addAttribute("lonMax", $r->getLonMax());
        $route->addAttribute("vehicle", $r->getVehicleType());
        $route->addAttribute("sortOrder", $r->getPosition());
        $directionsArray = Direction::getDirections($r);
        foreach ($directionsArray as $d) {
            $dir = $route->addChild("direction");
            $dir->addAttribute("tag", $d->getTag());
            $dir->addAttribute("title", $d->getPrettyTitle());
            $dir->addAttribute("name", $d->getPrettyName());
            $dir->addAttribute("show", $d->getShow() ? "true" : "false");
            $dir->addAttribute("useForUI", $d->getUseForUi() ? "true" : "false");
            $dbObj->bindParams(array($d->getId()));
            $stopDirMap = $dbObj->get_results("SELECT a.tag, b.position\n                                                FROM stop as a, stop_direction_map as b\n                                                WHERE a.id=b.stop_id AND b.direction_id=?\n                                                ORDER BY b.position");
            if ($dbObj->num_rows > 0) {
                foreach ($stopDirMap as $m) {
                    $map = $dir->addChild("stop");
                    $map->addAttribute("tag", $m->tag);
                }
            }
        }
    }
    $fileName = Util::getBaseDirectoryPath(Util::XML_FILE) . $agencyObj->getShortTitle() . ".xml";
    Util::prettyPrintXml($xml, $fileName);
}
 /**
  * Gets all the routes that are registered
  *
  * @return array
  */
 private function getRoutes()
 {
     if ($this->isLumen()) {
         return app()->getRoutes();
     } else {
         $routes = \Route::getRoutes();
         $array = [];
         /** @var Route $route */
         foreach ($routes as $route) {
             foreach ($route->getMethods() as $method) {
                 $array[] = ['method' => $method, 'uri' => $route->getPath(), 'action' => $route->getAction()];
             }
         }
         return $array;
     }
 }
 /**
  * @Get("test99999", lilichun123="chun")
  */
 public function index()
 {
     return response(['aa' => '123'], 400);
     dd(app(\App\Contracts\IAclModule::class)->routeModuleList());
     die;
     foreach (\Route::getRoutes() as $item) {
         dd($item->getAction());
     }
     die;
     dump(\Route::currentRouteAction());
     foreach (\Route::getRoutes() as $item) {
         //            dd($item);
         dump($item->getAction());
     }
     return '123123';
 }
Example #23
0
 function philsroutes()
 {
     $routeCollection = Route::getRoutes();
     echo "<table style='width:100%'>";
     echo "<tr>";
     echo "<td width='10%'><h4>HTTP Method</h4></td>";
     echo "<td width='10%'><h4>Route</h4></td>";
     echo "<td width='80%'><h4>Corresponding Action</h4></td>";
     echo "</tr>";
     foreach ($routeCollection as $value) {
         echo "<tr>";
         echo "<td>" . $value->getMethods()[0] . "</td>";
         echo "<td><a href='" . $value->getPath() . "' target='_blank'>" . $value->getPath() . "</a> </td>";
         echo "<td>" . $value->getActionName() . "</td>";
         echo "</tr>";
     }
     echo "</table>";
 }
Example #24
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $routes = \Route::getRoutes()->getRoutes();
     foreach ($routes as $route) {
         $outputFile = config('staticfy.output_path') . '/' . ($route->getUri() == '/' ? 'index.html' : $route->getUri());
         $req = \Illuminate\Http\Request::create($route->getUri());
         $route->bind($req);
         $response = $route->run($req);
         if (is_a($response, 'Illuminate\\View\\View')) {
             $dir = dirname($outputFile);
             if (!is_dir($dir)) {
                 mkdir($dir, 0755, true);
             }
             file_put_contents($outputFile, $response->render());
             $this->info($outputFile);
         }
     }
 }
Example #25
0
 public function importar_rutas()
 {
     //Consulta rutas registradas en tabla acciones
     $arr_rutas = Accion::lists('ruta');
     //Obiene rutas registradas
     $routeCollection = Route::getRoutes();
     foreach ($routeCollection as $route) {
         $ruta = $route->getPath();
         if (array_search($ruta, $arr_rutas) === false) {
             //Si no se encuentra el valor de la ruta: Inserta ruta en acciones
             $accion = new Accion();
             $accion->ruta = $ruta;
             $accion->activo = false;
             $accion->save();
             //Agrega ruta nueva a arreglo para no duplicar rutas
             $arr_rutas[] = $ruta;
         }
     }
 }
Example #26
0
 /**
  * 设置list
  */
 protected function setList()
 {
     $routes = \Route::getRoutes();
     foreach ($routes as $route) {
         $arr = array();
         $actionName = $route->getActionName();
         preg_match('/\\@/', $actionName, $end, PREG_OFFSET_CAPTURE);
         if (!isset($end[0])) {
             continue;
         }
         $controller = substr($actionName, 0, $end[0][1]);
         $arr['controller'] = $controller;
         $action = substr($actionName, $end[0][1] + 1);
         $arr['action'] = $action;
         $arr['method'] = $route->getMethods()[0];
         $arr['uri'] = $route->getPath();
         array_push($this->list, $arr);
     }
 }
Example #27
0
 public function fire()
 {
     foreach (\Route::getRoutes() as $route) {
         $name = $route->getAction();
         $permission = Permission::where('name', '=', $name)->first();
         if (is_null($permission)) {
             $permission = new Permission();
             $permission->name = $name;
             try {
                 $permission->save();
             } catch (\Exception $e) {
                 $this->error($e->getMessage());
             }
             $this->info("{$name} permission added.");
         } else {
             $this->comment("{$name} permission exists.");
         }
     }
 }
 public function updateStopDirMap()
 {
     /**
      * @var DB
      */
     $dbObj = DBPool::getInstance();
     $routeArray = Route::getRoutes($this->agency);
     $stopArray = Stop::getStops($this->agency);
     $bartApiKey = $this->appConfig['BART_API_KEY'];
     foreach ($routeArray as $routeTag => $routeObj) {
         $pos = 0;
         $directionArray = Direction::getDirections($routeObj);
         foreach ($directionArray as $dirTag => $dirObj) {
             //We're only interested in the directions we're showing
             if (!$dirObj->getShow()) {
                 continue;
             }
             //Fetch the direction details
             $apiURL = str_replace(BartApiEndPoints::DIRECTION, $dirObj->getTag(), BartApiEndPoints::ROUTE_INFO . $bartApiKey);
             $dirInfoXmlBuilder = new XmlObjBuilder($apiURL);
             $dirInfoXml = $dirInfoXmlBuilder->getXmlObj();
             foreach ($dirInfoXml->routes->route->config as $c) {
                 foreach ($c as $station) {
                     $pos++;
                     $stopTag = (string) $station;
                     $tempStopObj = $stopArray[$stopTag];
                     $stopId = $tempStopObj->getId();
                     $tempDirObj = $directionArray[$dirTag];
                     $dirId = $tempDirObj->getId();
                     $dbObj->bindParams(array($stopId, $dirId, $pos, TableUpdate::getVersion()));
                     $dbObj->query("INSERT INTO stop_direction_map\n                            (stop_id, direction_id, position, version, created_date)\n                            VALUES (?, ?, ?, ?, NOW())");
                     if ($dbObj->rows_affected != 1) {
                         //TODO: Log it
                     }
                 }
                 //Stations
             }
         }
         //Directions
     }
     //Routes
 }
Example #29
0
 /**
  * test all route
  *
  * @group route
  */
 public function testAllRoute()
 {
     $routeCollection = Route::getRoutes();
     $this->withoutEvents();
     $blacklist = ['/', '_debugbar/open', 'images/all', 'admin/logout'];
     $dynamicReg = "/{\\S*}/";
     //used for omitting dynamic urls that have {} in uri (http://laravel-tricks.com/tricks/adding-a-sitemap-to-your-laravel-application#comment-1830836789)
     $this->be($this->admin);
     foreach ($routeCollection as $route) {
         if (!preg_match($dynamicReg, $route->getUri()) && in_array('GET', $route->getMethods()) && !in_array($route->getUri(), $blacklist)) {
             $start = $this->microtimeFloat();
             fwrite(STDERR, print_r('test ' . $route->getUri() . "\n", true));
             $response = $this->call('GET', $route->getUri());
             $end = $this->microtimeFloat();
             $temps = round($end - $start, 3);
             fwrite(STDERR, print_r('time: ' . $temps . "\n", true));
             $this->assertLessThan(15, $temps, "too long time for " . $route->getUri());
             $this->assertEquals(200, $response->getStatusCode(), $route->getUri() . " failed to load");
         }
     }
 }
Example #30
0
 /**
  * 根据路由 $route 处理当前导航URL,用于匹配导航高亮
  *
  * @param string $route 点分式路由别名
  * @return string 返回经过处理之后路径
  */
 function currentNav($route = '')
 {
     // dashboard.system.setting
     $routeArray = explode('.', $route);
     // 后台的路由前缀都是 dashboard, 出现 dashboard/*/ 的链接是一级链接
     if (is_array($routeArray) && count($routeArray) > 2) {
         // 二级链接
         // 如 kratos.com/dashboard/article  对应的路由别名是 dashboard.article.index, 所以碰到别名有 index 的要手动加上
         if ($routeArray[2] == 'index') {
             $route1 = $route;
         } else {
             // 三级链接
             $route1 = preg_replace('/[^\\.]*$/i', 'index', $route, 1);
         }
         if (Route::getRoutes()->hasNamedRoute($route1)) {
             return route($route1);
         }
         return route($route);
     }
     return route($route);
 }