本文整理汇总了PHP中Route::getRoutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getRoutes方法的具体用法?PHP Route::getRoutes怎么用?PHP Route::getRoutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Route
的用法示例。
在下文中一共展示了Route::getRoutes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAllRoutesHaveAuthorization
/**
* 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)');
}
}
}
示例2: testIsInValidGenerateRoute
public function testIsInValidGenerateRoute()
{
$invalidRoute = 'generate';
$routeCollection = Route::getRoutes();
$isValidRoute = $this->generator->checkRouteIsValid($invalidRoute, $routeCollection);
$this->assertFalse($isValidRoute);
}
示例3: getRoutes
/**
* 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>";
}
}
示例4: returnRoute
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();
}
示例5: GET_createGroupForm
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();
}
示例6: getAllExisting
protected function getAllExisting()
{
try {
return Route::getRoutes($this->agency, TableUpdate::getLiveVersion());
} catch (Exception $ex) {
return false;
}
}
示例7: __construct
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'] : '')];
}
}
示例8: link_to_route
/**
* 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>';
}
}
示例9: testAllDisplayPages
/**
* 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);
}
}
示例10: getSlugsInvalid
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);
}
示例11: steps
/**
* 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;
}
示例12: getRouteActions
/**
* 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;
}
示例13: getRoutes
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;
}
示例14: getData
/**
* @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);
}
示例15: createForm
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;
}