当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::getCurrentRoute方法代码示例

本文整理汇总了PHP中Illuminate\Routing\Router::getCurrentRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getCurrentRoute方法的具体用法?PHP Router::getCurrentRoute怎么用?PHP Router::getCurrentRoute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Routing\Router的用法示例。


在下文中一共展示了Router::getCurrentRoute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: invoke

 /**
  * Call internal URI with parameters.
  *
  * @param  string $uri
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function invoke($uri, $method, $parameters = array())
 {
     // Request URI.
     $uri = '/' . ltrim($uri, '/');
     // Parameters for GET, POST
     $parameters = $parameters ? current($parameters) : array();
     try {
         // store the original request data and route
         $originalInput = $this->request->input();
         $originalRoute = $this->router->getCurrentRoute();
         // create a new request to the API resource
         $request = $this->request->create($uri, strtoupper($method), $parameters);
         // replace the request input...
         $this->request->replace($request->input());
         $dispatch = $this->router->dispatch($request);
         if (method_exists($dispatch, 'getOriginalContent')) {
             $response = $dispatch->getOriginalContent();
         } else {
             $response = $dispatch->getContent();
         }
         // Decode json content.
         if ($dispatch->headers->get('content-type') == 'application/json') {
             if (function_exists('json_decode') and is_string($response)) {
                 $response = json_decode($response, true);
             }
         }
         // replace the request input and route back to the original state
         $this->request->replace($originalInput);
         $this->router->setCurrentRoute($originalRoute);
         return $response;
     } catch (NotFoundHttpException $e) {
     }
 }
开发者ID:ddedic,项目名称:nexsell,代码行数:41,代码来源:Api.php

示例2: pageUrl

 /**
  * Generate a page URL, based on the request's current URL.
  *
  * @param int  $page
  * @param bool $full Return the full version of the URL in for the first page
  *                   Ex. /users/page/1 instead of /users
  *
  * @return string
  */
 public function pageUrl($page, $full = false)
 {
     $currentPageUrl = $this->router->getCurrentRoute()->getUri();
     $url = $this->addPageQuery(str_replace('{pageQuery?}', '', $currentPageUrl), $page, $full);
     foreach ($this->router->getCurrentRoute()->bindParameters(app('request')) as $parameterName => $parameterValue) {
         $url = str_replace(['{' . $parameterName . '}', '{' . $parameterName . '?}'], $parameterValue, $url);
     }
     return $this->urlGenerator->to($url);
 }
开发者ID:hugofabricio,项目名称:laravel-paginateroute,代码行数:18,代码来源:PaginateRoute.php

示例3: getControllerAndAction

 /**
  * Get controller and action from current route
  *
  * @return array
  */
 protected function getControllerAndAction()
 {
     $name = $this->router->getCurrentRoute()->getActionName();
     // don't allow closures for routes protected by this middleware
     if (!str_contains($name, '@')) {
         throw new \LogicException('Closures for routes not allowed in this application');
     }
     return explode('@', $name);
 }
开发者ID:mnabialek,项目名称:laravel-authorize,代码行数:14,代码来源:Authorize.php

示例4: hasAccess

 /**
  * @param null $routeName
  * @return bool
  */
 public function hasAccess($routeName = null)
 {
     if ($routeName === null) {
         $routeName = $this->router->getCurrentRoute()->getName();
         if ($routeName === null) {
             return true;
         }
     }
     return $this->hasPermissionName($routeName);
 }
开发者ID:morilog,项目名称:acl,代码行数:14,代码来源:Acl.php

示例5: invoke

 /**
  * Call internal URI with parameters.
  *
  * @param  string $uri
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function invoke($uri, $method, $parameters = array())
 {
     // Request URI.
     $uri = '/' . ltrim($uri, '/');
     try {
         // Store the original request data and route.
         $originalInput = $this->request->input();
         $originalRoute = $this->router->getCurrentRoute();
         // Masking route to allow testing with PHPUnit.
         // if ( ! $originalRoute instanceof Route)
         // {
         //     $originalRoute = new Route(new \Symfony\Component\HttpFoundation\Request());
         // }
         $requestMethod = strtoupper($method);
         // Create a new request to the API resource
         $request = $this->request->create($uri, $requestMethod, $parameters);
         // Replace request method and input.
         $this->request->setMethod($requestMethod);
         $this->request->replace($request->input());
         // Dispatch request.
         $dispatch = $this->router->dispatch($request);
         if (method_exists($dispatch, 'getOriginalContent')) {
             $response = $dispatch->getOriginalContent();
         } else {
             $response = $dispatch->getContent();
         }
         // Decode json content.
         if ($dispatch->headers->get('content-type') == 'application/json') {
             if (function_exists('json_decode') and is_string($response)) {
                 $response = json_decode($response, true);
             }
         }
         // Restore the request input and route back to the original state.
         $this->request->replace($originalInput);
         return $response;
     } catch (NotFoundHttpException $e) {
         throw new HmvcNotFoundHttpException('Request Not Found.');
     } catch (FatalErrorException $e) {
         throw new HmvcFatalErrorException($e->getMessage());
     }
 }
开发者ID:WebtoolsWendland,项目名称:laravel-hmvc,代码行数:49,代码来源:Hmvc.php

示例6: execute

 public function execute(array $args = null)
 {
     $self = $this;
     $this->layout->setEnvironment($this->viewFactory);
     if (null === $args) {
         $args = $this->router->getCurrentRoute()->parametersWithoutNulls();
     }
     foreach ($this->structure as $block => $callback_list) {
         $blocks = array();
         foreach ($callback_list as $callback) {
             $response = $this->handleResponse($this->callCallback($callback, $args));
             if (true === $response instanceof Response) {
                 return $response;
             }
             $blocks[] = $response;
         }
         $this->layout->with($block, join("\n", $blocks));
     }
     $this->layout->with($this->data);
     return $this->layout;
 }
开发者ID:desmart,项目名称:laravel-layout,代码行数:21,代码来源:Controller.php

示例7: callFilter

 /**
  * Call a given filter with the parameters.
  *
  * @param  string  $name
  * @param  \Symfony\Component\HttpFoundation\Request  $request
  * @param  array   $params
  * @return mixed
  */
 public function callFilter($name, Request $request, array $params = array())
 {
     if (!$this->router->filtersEnabled()) {
         return;
     }
     $merge = array($this->router->getCurrentRoute(), $request);
     $params = array_merge($merge, $params);
     // Next we will parse the filter name to extract out any parameters and adding
     // any parameters specified in a filter name to the end of the lists of our
     // parameters, since the ones at the beginning are typically very static.
     list($name, $params) = $this->parseFilter($name, $params);
     if (!is_null($callable = $this->router->getFilter($name))) {
         return call_user_func_array($callable, $params);
     }
 }
开发者ID:shinichi81,项目名称:laravel4demo,代码行数:23,代码来源:Route.php

示例8: previousPageUrl

 /**
  * Get the previous page url
  * 
  * @param  bool $full  Return the full version of the url in for the first page
  *                     Ex. /users/page/1 instead of /users
  * @return string|null
  */
 public function previousPageUrl($full = false)
 {
     $previousPage = $this->previousPage();
     if ($previousPage === null) {
         return null;
     }
     // This should call the current action with a different parameter
     // Afaik there's no cleaner way to do this
     $currentPageUrl = new String($this->router->getCurrentRoute()->getUri());
     if ($previousPage === 1 && !$full) {
         $previousPageUrl = $currentPageUrl->replaceLast($this->pageName . '/{page}', '');
     } else {
         $previousPageUrl = $currentPageUrl->replaceLast('{page}', $previousPage);
     }
     return $this->urlGenerator->to($previousPageUrl);
 }
开发者ID:jjsquad,项目名称:laravel-paginateroute,代码行数:23,代码来源:PaginateRoute.php

示例9: invoke

 /**
  * Call internal URI with parameters.
  *
  * @param  string $uri
  * @param  string $method
  * @param  array  $parameters
  * @return mixed
  */
 public function invoke($uri, $method, $parameters = array())
 {
     // Request URI.
     if (!preg_match('/^http(s)?:/', $uri)) {
         $uri = '/' . ltrim($uri, '/');
     }
     try {
         // Store the original request data and route.
         $originalInput = $this->request->input();
         $originalRoute = $this->router->getCurrentRoute();
         // Masking route to allow testing with PHPUnit.
         /*if ( ! $originalRoute instanceof Route)
           {
               $originalRoute = new Route(new \Symfony\Component\HttpFoundation\Request());
           }*/
         // Create a new request to the API resource
         $request = $this->request->create($uri, strtoupper($method), $parameters);
         // Replace the request input...
         $this->request->replace($request->input());
         // Dispatch request.
         $dispatch = $this->router->dispatch($request);
         if (method_exists($dispatch, 'getOriginalContent')) {
             $response = $dispatch->getOriginalContent();
         } else {
             $response = $dispatch->getContent();
         }
         // Decode json content.
         if ($dispatch->headers->get('content-type') == 'application/json') {
             if (function_exists('json_decode') and is_string($response)) {
                 $response = json_decode($response, true);
             }
         }
         // Restore the request input and route back to the original state.
         $this->request->replace($originalInput);
         // This method have been removed from Laravel.
         //$this->router->setCurrentRoute($originalRoute);
         return $response;
     } catch (NotFoundHttpException $e) {
         //trigger_error('Not found');
         var_dump($e->getMessage());
     } catch (FatalErrorException $e) {
         var_dump($e->getMessage());
     }
 }
开发者ID:elijan,项目名称:laravel4-api,代码行数:52,代码来源:Api.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, Router $router)
 {
     /** @var Model $listClass */
     $listClass = app($this->getListClassName());
     $builder = $listClass->newQuery();
     foreach ($request->get('sorting', []) as $field => $direction) {
         $builder->orderBy($field, $direction);
     }
     // foreach
     /** @var Paginator $pagination */
     $pagination = $builder->where($request->get('filter', []))->paginate((int) $request->get('limit', 30))->appends($request->query());
     $count = count($pagination);
     $return = [];
     if ($total = $pagination->total()) {
         $baseURI = $router->getCurrentRoute()->getUri();
         $rows = [];
         $links = ['self' => ['href' => $pagination->url($pagination->currentPage())]];
         if ($total > $count) {
             $links['first'] = ['href' => $pagination->url(1)];
             $links['last'] = ['href' => $pagination->url($pagination->lastPage())];
             if ($pagination->hasMorePages()) {
                 $links['next'] = ['href' => $pagination->nextPageUrl()];
             }
             if ($pagination->currentPage() > 1) {
                 $links['prev'] = ['href' => $pagination->previousPageUrl()];
             }
             // if
         }
         /** @var Model $row */
         foreach ($pagination as $index => $row) {
             $rows[$index] = array_merge(['_links' => ['self' => ['href' => url($baseURI, $row->id)]]], $row->toArray());
         }
         $return = ['_embedded' => [$listClass->getTable() => $rows], '_links' => $links, 'count' => $count, 'take' => $pagination->perPage(), 'total' => $total];
     } else {
         if (!$count) {
             abort(404);
         }
     }
     // elseif
     // TODO 205, links in list.
     return $return;
 }
开发者ID:b3nl,项目名称:laravel-rest-scaffolding,代码行数:47,代码来源:PaginationTrait.php

示例11: getCurrentRoute

 /**
  * Get the currently dispatched route instance.
  *
  * @return \Illuminate\Routing\Route 
  * @static 
  */
 public static function getCurrentRoute()
 {
     return \Illuminate\Routing\Router::getCurrentRoute();
 }
开发者ID:satriashp,项目名称:tour,代码行数:10,代码来源:_ide_helper.php

示例12: getRouteName

 /**
  * Return current route name
  *
  * @return string
  */
 protected function getRouteName()
 {
     return $this->router->getCurrentRoute()->getName();
 }
开发者ID:understand,项目名称:understand-laravel5,代码行数:9,代码来源:FieldProvider.php

示例13: listMembers

 /**
  * Return data for all members within the system
  *
  * @return array
  */
 public function listMembers(Router $router)
 {
     $uri = $router->getCurrentRoute()->uri();
     $users = User::whereRaw('id != 1')->orderBy('created_at')->get();
     foreach ($users as $key => $user) {
         foreach ($user->standings as $standing) {
             if (empty($standing->end_date)) {
                 $user->activeStanding = $standing->type;
             }
         }
     }
     return view('members.list', compact('uri', 'users'));
 }
开发者ID:staciewilhelm,项目名称:denver-member-tracking,代码行数:18,代码来源:MemberController.php

示例14: callAfterFilters

 /**
  * Call the after filters on the controller.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @param  string  $method
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @return mixed
  */
 protected function callAfterFilters($router, $method, $response)
 {
     $route = $router->getCurrentRoute();
     // When running the before filters we will simply spin through the list of the
     // filters and call each one on the current route objects, which will place
     // the proper parameters on the filter call, including the requests data.
     $request = $router->getRequest();
     $filters = $this->getAfterFilters($request, $method);
     foreach ($filters as $filter) {
         $this->callFilter($route, $filter, $request, array($response));
     }
 }
开发者ID:shinichi81,项目名称:laravel4demo,代码行数:20,代码来源:Controller.php


注:本文中的Illuminate\Routing\Router::getCurrentRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。