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


PHP Route::parameters方法代码示例

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


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

示例1: create

 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     return $this->redirector->to($this->parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
开发者ID:JoelESvensson,项目名称:redirects-module,代码行数:13,代码来源:RedirectResponse.php

示例2: create

 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     if (!starts_with($url = $redirect->getTo(), ['http://', 'https://', '//'])) {
         $url = $this->url->to($redirect->getTo(), [], $redirect->isSecure());
     }
     return $this->redirector->to(rtrim($this->parser->parse($url, $parameters), '/'), $redirect->getStatus());
 }
开发者ID:visualturk,项目名称:redirects-module,代码行数:16,代码来源:RedirectResponse.php

示例3: handle

 /**
  * Handle the command.
  *
  * @param RedirectRepositoryInterface $redirects
  * @param Redirector                  $redirector
  * @param Parser                      $parser
  * @param Route                       $route
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(RedirectRepositoryInterface $redirects, Redirector $redirector, Parser $parser, Route $route)
 {
     $redirect = $redirects->find($this->id);
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($route->parameterNames())), $route->parameters());
     return $redirector->to($parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
开发者ID:AkibaTech,项目名称:redirects-module,代码行数:17,代码来源:GetRedirectResponse.php

示例4: showCollection

 public function showCollection(Route $route, Router $router)
 {
     // We extract the params not set in the query from the URL
     $queryParams = $route->parameters();
     // Figure out the page from the route URL parameters
     $page = max(1, $route->getParameter('page'));
     $routeParams = $route->getAction();
     $query = $routeParams['query'];
     $articles = PressFacade::query($query, $queryParams);
     if (0 === $articles->count() && $page !== 1) {
         return abort(404);
     }
     // create a paginator if required
     if ($routeParams['paginate']) {
         $page_size = PressFacade::getConf('default_page_size');
         $paginator = $articles->getPaginator($page_size);
         $articles = $articles->forPage($page, $page_size);
     } else {
         $paginator = $articles->getPaginator(999999);
     }
     // decide the view. If it is provided with the query options, just use
     // it. if it is provided with a theme wildcard, use the default theme
     // else try to find a 'collection' view in the default theme.
     // Also, the user can set a theme to load the assets from.
     $theme = array_get($routeParams, 'theme', PressFacade::getConf('theme'));
     if (isset($routeParams['view'])) {
         $viewName = str_replace('_::', "{$theme}::", $routeParams['view']);
         $view = View::make($viewName);
     } else {
         $view = View::make("{$theme}::collection");
     }
     // paginator base path
     $baseUrlParamNames = $this->getRouteParamNames($routeParams['base_route'], $router);
     $baseUrlParams = array_only($queryParams, $baseUrlParamNames);
     $basePath = \URL::route($routeParams['base_route'], $baseUrlParams);
     $paginator->setBasePath($basePath);
     // metadata from the page can be defined trough the route
     $meta = (object) array_get($routeParams, 'meta', []);
     return $view->with('meta', SEO::getMeta())->with('articles', $articles)->with('cacheInfo', PressFacade::editingCacheInfo())->with('themeAssets', PressFacade::getThemeAssets($theme))->with('paginator', $paginator);
 }
开发者ID:lud,项目名称:press,代码行数:40,代码来源:PressPubController.php

示例5: substituteImplicitBindings

 /**
  * Substitute the implicit Eloquent model bindings for the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return void
  */
 public function substituteImplicitBindings($route)
 {
     $parameters = $route->parameters();
     foreach ($route->signatureParameters(Model::class) as $parameter) {
         $class = $parameter->getClass();
         if (array_key_exists($parameter->name, $parameters) && !$route->getParameter($parameter->name) instanceof Model) {
             $method = $parameter->isDefaultValueAvailable() ? 'first' : 'firstOrFail';
             $model = $class->newInstance();
             $route->setParameter($parameter->name, $model->where($model->getRouteKeyName(), $parameters[$parameter->name])->{$method}());
         }
     }
 }
开发者ID:samlev,项目名称:framework,代码行数:18,代码来源:Router.php

示例6: alternates

 public function alternates(LaravelRoute $route)
 {
     if (!$route instanceof Route) {
         return [];
     }
     $alternates = [];
     $parameters = $route->parameters();
     foreach ($this->routes as $alternate) {
         if ($route->isAlternate($alternate)) {
             $alternates[] = $alternate;
         }
     }
     return $alternates;
 }
开发者ID:xel1045,项目名称:laravel-module,代码行数:14,代码来源:Router.php

示例7: substituteBindings

 /**
  * Substitute the route bindings onto the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return \Illuminate\Routing\Route
  */
 protected function substituteBindings($route)
 {
     foreach ($route->parameters() as $key => $value) {
         if (isset($this->binders[$key])) {
             $route->setParameter($key, $this->performBinding($key, $value, $route));
         }
     }
     return $route;
 }
开发者ID:hramose,项目名称:Sistema-Control-de-Almacen,代码行数:15,代码来源:Router.php

示例8: substituteImplicitBindings

 /**
  * Substitute the implicit Eloquent model bindings for the route.
  *
  * @param  \Illuminate\Routing\Route  $route
  * @return void
  */
 protected function substituteImplicitBindings($route)
 {
     $parameters = $route->parameters();
     foreach ($route->signatureParameters(Model::class) as $parameter) {
         $class = $parameter->getClass();
         if (array_key_exists($parameter->name, $parameters)) {
             $method = $parameter->isDefaultValueAvailable() ? 'find' : 'findOrFail';
             $route->setParameter($parameter->name, $class->newInstance()->{$method}($parameters[$parameter->name]));
         }
     }
 }
开发者ID:janhartigan,项目名称:framework,代码行数:17,代码来源:Router.php

示例9: parseParameters

 public function parseParameters(Route $route)
 {
     $parameters = $route->parameters();
     $parameters['_route'] = $this->request->getPathInfo();
     $action = $route->getAction();
     // Controller@action
     if (is_string($action)) {
         list($parameters['_controller'], $parameters['action']) = explode('@', $action[0]);
         return $parameters;
     } else {
         if (isset($action['controller'])) {
             list($parameters['_controller'], $parameters['action']) = explode('@', $action['controller']);
             return $parameters;
         } else {
             if (isset($action['uses']) && !empty($action['uses'])) {
                 // Callable
                 if (is_callable($action['uses'])) {
                     $parameters['_controller'] = $action['uses'];
                     $parameters['action'] = $action['uses'];
                     return $parameters;
                     // 'uses' => 'Controller@action'
                 } else {
                     if (is_string($action['uses']) && strpos($action['uses'], '@') !== false) {
                         list($parameters['_controller'], $parameters['action']) = explode('@', $action['uses']);
                         return $parameters;
                     }
                 }
             }
         }
     }
     throw new \RuntimeException('Unable to parse laravel route parameters');
 }
开发者ID:ppi,项目名称:ppi-laravel-router,代码行数:32,代码来源:LaravelRouterWrapper.php

示例10: parameters

 /**
  * Get the key / value list of parameters for the route.
  *
  * @return array
  */
 public function parameters()
 {
     if ($this->condition) {
         global $post, $wp_query;
         // Pass WordPress globals to closures or controller methods as parameters.
         $parameters = array_merge($this->parameters, ['post' => $post, 'query' => $wp_query]);
         // When no posts, $post is null.
         // When is null, set the parameter value of $post to false.
         // This avoid missing arguments in methods for routes or controllers.
         if (is_null($parameters['post'])) {
             $parameters['post'] = false;
         }
         $this->parameters = $parameters;
         return $parameters;
     }
     return parent::parameters();
 }
开发者ID:themosis,项目名称:framework,代码行数:22,代码来源:Route.php


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