本文整理汇总了PHP中Illuminate\Routing\Route::getUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getUri方法的具体用法?PHP Route::getUri怎么用?PHP Route::getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Route
的用法示例。
在下文中一共展示了Route::getUri方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addToCollections
/**
* Add the given route to the arrays of routes.
*
* @param \Illuminate\Routing\Route $route
* @return void
*/
protected function addToCollections($route)
{
foreach ($route->methods() as $method) {
$this->routes[$method][$route->domain() . $route->getUri()] = $route;
}
$this->allRoutes[$method . $route->domain() . $route->getUri()] = $route;
}
示例2: addToCollections
/**
* Add the given route to the arrays of routes.
*
* @param \Illuminate\Routing\Route $route
* @return void
*/
protected function addToCollections($route)
{
$domainAndUri = $route->domain() . $route->getUri() . $route->getPriority();
foreach ($route->methods() as $method) {
$this->routes[$method][$domainAndUri] = $route;
}
$this->allRoutes[$method . $domainAndUri] = $route;
}
示例3: isAlternate
public function isAlternate(LaravelRoute $route)
{
if (!$route instanceof Route) {
return false;
}
// Validate methods
if ($this->methods() != $route->methods()) {
return false;
}
// Validate scheme
if ($this->httpOnly() !== $route->httpOnly()) {
return false;
}
// Validate base uri
if ($this->getBaseUri() !== $route->getBaseUri()) {
return false;
}
if ($this->getUri() === $route->getUri()) {
return false;
}
return true;
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Route $route)
{
return view('pages.category_index')->with('data', ['items' => $this->getModel(), 'route' => $route, 'uri' => $route->getUri(), 'body_class' => $route->getUri(), 'title' => $this->getPageTitle()]);
}
示例5: subordinates
/**
* Returns a given route's children as an array. A parent route like /users would return (if they existed) all routes
* like /users/{userid}, /users/new.
*
* @param Route $parentRoute
* @return Route[]
*/
public function subordinates(Route $parentRoute)
{
if (array_key_exists($parentRoute->getUri(), $this->subordinateRouteCache)) {
return $this->subordinateRouteCache[$parentRoute->getUri()];
}
$routes = $this->router->getRoutes();
$children = [];
/** @var Route $route */
foreach ($routes as $route) {
if (!self::isValid($route)) {
continue;
}
// if the route does not start with the same uri as the current route -> skip
if ($parentRoute->getUri() != '/' && !starts_with($route->getUri(), $parentRoute->getUri())) {
continue;
}
// if route equals the parent route
if ($parentRoute->getActionName() == $route->getActionName()) {
continue;
}
$children[] = $route;
}
return $this->subordinateRouteCache[$parentRoute->getUri()] = $children;
}
示例6: getUri
/**
* @param Route $route
*
* @return mixed
*/
protected function getUri($route)
{
return $route->getUri();
}
示例7: getUri
/**
* @return string
*/
public function getUri()
{
return parent::getUri() . $this->getRouteIntent();
}
示例8: generateJsString
private function generateJsString(Route $route)
{
$jsRoutes = "'" . $this->appUrl . '/' . $route->getUri() . "',";
return $jsRoutes;
}
示例9: generateStandartRoute
/**
* Generate Route into standart routing in route file
*
* @param string $route_file
* @param Illuminate\Routing\Route $route
* @return void
*/
protected function generateStandartRoute($route_file, Route $route)
{
$route_methods = $route->getMethods();
$method = '';
$uri = $route->getUri();
$extra_param = '';
// first param for Route::match
switch ($route_methods) {
case ['GET', 'HEAD']:
case ['GET']:
$method = 'get';
break;
case ['POST']:
case ['PUT']:
case ['PATCH']:
case ['DELETE']:
$method = strtolower($route_methods[0]);
break;
default:
$method = 'match';
$arr_methods = array_map(function ($val) {
return "'" . strtolower($val) . "'";
}, $route_methods);
$extra_param = '[' . implode(', ', $arr_methods) . ']';
}
$action = $route->getAction();
$action_data = [];
$uses = str_replace($action['namespace'] . "\\", "", $action['uses']);
$action_data['uses'] = "'uses' => '{$uses}'";
if (!empty($action['as'])) {
$action_data['as'] = "'as' => '" . $action['as'] . "'";
}
if (!empty($action['middleware'])) {
$action_data['middleware'] = "'middleware' => '" . implode('|', $action['middleware']) . "'";
}
if (!empty($action['prefix'])) {
$action_data['prefix'] = "'prefix' => '" . $action['prefix'] . "'";
}
// if only action uses in action_data, just use string as action
if (1 == count($action_data) and array_key_exists('uses', $action_data)) {
$code_action_params = "'{$uses}'";
} else {
$code_action_params = "[\n\t" . implode(",\n\t", $action_data) . "\n]";
}
$route_params = [];
if (!empty($extra_param)) {
$route_params[] = $extra_param;
}
$route_params[] = "'{$uri}'";
$route_params[] = $code_action_params;
$route_code = "\nRoute::{$method}(" . implode(', ', $route_params) . ")";
$code_conditions = [];
foreach ($route->conditions as $param => $regex) {
$code_conditions[] = "->where('{$param}', '{$regex}')";
}
$route_code .= implode("\n", $code_conditions) . ";";
if (false == $this->option("no-comment")) {
$code_comment = "\n\n/*" . "\n | -----------------------------------------------------------" . "\n | Route " . (isset($action['as']) ? "'" . $action['as'] . "'" : "") . "\n | -----------------------------------------------------------" . (!empty($route->description) ? "\n | " . str_replace("\n", "\n | ", $route->description) . "\n | " : "") . "\n | generated at: " . date('Y-m-d H:i:s') . "\n |" . "\n */";
$route_code = $code_comment . $route_code;
} else {
$route_code = "\n" . $route_code;
}
file_put_contents($route_file, file_get_contents($route_file) . $route_code);
}