本文整理汇总了PHP中Illuminate\Routing\Route类的典型用法代码示例。如果您正苦于以下问题:PHP Route类的具体用法?PHP Route怎么用?PHP Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Route类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addLookups
/**
* Add the route to any look-up tables if necessary.
*
* @param Route $route illuminate route
*
* @return void
*/
protected function addLookups($route)
{
// If the route has a name, we will add it to the name look-up table so that we
// will quickly be able to find any route associate with a name and not have
// to iterate through every route every time we need to perform a look-up.
$action = $route->getAction();
if (isset($action['as'])) {
if (isset($action['module'])) {
$this->nameList[$action['module'] . "." . $action['as']] = $route;
} else {
$this->nameList[$action['as']] = $route;
}
}
// When the route is routing to a controller we will also store the action that
// is used by the route. This will let us reverse route to controllers while
// processing a request and easily generate URLs to the given controllers.
if (isset($action['controller'])) {
$this->addToActionList($action, $route);
}
if (isset($action['module'])) {
$this->addToModuleList($action, $route);
}
if (isset($action['settings_menu'])) {
$this->addToSettingsMenuList($route);
}
}
示例2: setRoute
/**
* @param RouteInstance $route
*/
public function setRoute(RouteInstance $route)
{
// Compile route
$request = new Request();
$route->matches($request);
$this->route = $route;
}
示例3: matches
/**
* Validate a given rule against a route and request.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function matches(Route $route, Request $request)
{
if (is_null($route->hostExpression())) {
return true;
}
return preg_match($route->hostExpression(), $request->getHost());
}
示例4: find
public function find(Route $route)
{
$manuales = manuales::find($route->getParameter('manuales'));
if (!$manuales) {
abort(404);
}
}
示例5: getControllerName
function getControllerName()
{
$route = new Route();
print $route->getActionName();
print "<br />";
print $route->getAction();
}
示例6: matches
/**
* Validate a given rule against a route and request.
*
* @param BaseRoute $route
* @param Request $request
* @return bool
*/
public function matches(BaseRoute $route, Request $request)
{
if (!$route instanceof Route) {
return false;
}
return $route->getIntent() === (new Interpreter($request, $route->getWsdl()))->getIntent();
}
示例7: filterRouteAsClass
protected function filterRouteAsClass(Route $route)
{
if ($this->option('name') && !str_contains($route->getName(), $this->option('name')) || $this->option('path') && !str_contains(implode('|', $route->methods()) . ' ' . $route->uri(), $this->option('path'))) {
return null;
}
return $route;
}
示例8: link
/**
* 메뉴의 링크를 생성하여 반환한다. 메뉴에 link정보가 있을 경우 link정보를 우선 사용하여 생성한다.
* 그 다음으로 메뉴에 연결된 route정보를 사용하여 링크를 생성한다.
*
* @return Route|mixed|string
* @throws \Exception
*/
public function link()
{
if ($this->display === false) {
return '#';
}
// menu에 링크 정보가 있을 경우
if ($this->link !== null) {
if ($this->link instanceof Closure) {
return $this->link();
} else {
return $this->link;
}
}
// 어떤 링크정보도 찾을 수 없으면 #
if ($this->route === null) {
return '#';
}
// route 정보 사용
if ($name = $this->route->getName()) {
return route($name);
} elseif ($action = $this->route->getActionName()) {
if ($action !== 'Closure') {
return action($action);
}
}
throw new LinkNotFoundException('admin 메뉴가 지정된 route는 name(as)이 지정되어 있거나 Controller action이어야 합니다.');
}
示例9: matches
/**
* Validate a given rule against a route and request.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
* @return bool
*/
public function matches(Route $route, Request $request)
{
if (is_null($route->getCompiled()->getHostRegex())) {
return true;
}
return preg_match($route->getCompiled()->getHostRegex(), $request->getHost());
}
示例10: __construct
public function __construct(Route $route)
{
$this->middleware(function ($request, $next) {
// if session is not set get it from .env SHOP_CODE
if (!$request->session()->has('shop')) {
$shop = Shop::where('code', config('app.shop_code'))->first();
$request->session()->put('shop', $shop->id);
}
// if limit is not set default pagination limit
if (!$request->session()->has('limit')) {
$request->session()->put('limit', 100);
}
// if session is not set reset the session for the language
if (!$request->session()->has('language')) {
$request->session()->put('language', config('app.locale'));
}
// if session is not set reset the session for the basket
if (!$request->session()->has('basket')) {
$request->session()->put('basket', ['subtotal' => 0, 'count' => 0, 'items' => []]);
}
// global list of categories
$categories = Category::where('shop_id', $request->session()->get('shop'))->orderBy('order', 'asc')->get();
// share globals
view()->share('language', $request->session()->get('language'));
view()->share('categories', $categories);
return $next($request);
});
// add controller & action to the body class
$currentAction = $route->getActionName();
list($controller, $method) = explode('@', $currentAction);
$controller = preg_replace('/.*\\\\/', '', $controller);
$action = preg_replace('/.*\\\\/', '', $method);
view()->share('body_class', $controller . '-' . $action);
}
示例11: addParentIdsConditionsForDbObjectInjection
/**
* @param Route $route
* @param CmfDbObject $object
* @param array $conditions
*/
protected function addParentIdsConditionsForDbObjectInjection(Route $route, CmfDbObject $object, array &$conditions)
{
foreach ($route->parameterNames() as $name) {
if ($object->_hasField($name)) {
$conditions[$name] = $route->parameter($name);
}
}
}
示例12: findObservationFormatUser
/**
* Find the ObservationFormatUser or App Abort 404.
*/
public function findObservationFormatUser(Route $route)
{
$this->observation = ObservationFormatUser::findOrFail($route->getParameter('doit'));
$this->observation->load('answers.question');
$this->observation->answers = $this->observation->answers->sortBy(function ($answer, $key) {
return $answer->question->order;
});
}
示例13: extractPermissionFrom
/**
* Extracts the permission configured inside the route action array.
*
* @param Route $route
* @return string|null
*/
private function extractPermissionFrom(Route $route)
{
$parameters = $route->getAction();
if (isset($parameters['permission'])) {
return $parameters['permission'];
}
return null;
}
示例14: dispatch
/**
* Dispatch a request to a given controller and method.
*
* @param \Illuminate\Routing\Route $route
* @param mixed $controller
* @param string $method
* @return mixed
*/
public function dispatch(Route $route, $controller, $method)
{
$parameters = $this->resolveClassMethodDependencies($route->parametersWithoutNulls(), $controller, $method);
if (method_exists($controller, 'callAction')) {
return $controller->callAction($method, $parameters);
}
return call_user_func_array([$controller, $method], $parameters);
}
示例15: auth
public function auth(\Illuminate\Routing\Route $route, $request)
{
$action = explode('@', $route->getActionName());
$whiteList = ['showLogin', 'loginAction', 'logoutAction'];
if (\Session::get('cmslogin') == null && !in_array($action[1], $whiteList)) {
return \Redirect::to('/' . _LCMS_PREFIX_ . '/login');
}
}