コード例 #1
0
 /**
  * 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());
 }
コード例 #2
0
 /**
  * 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());
 }
コード例 #3
0
 /**
  * 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());
 }
コード例 #4
0
ファイル: PressPubController.php プロジェクト: lud/press
 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);
 }
コード例 #5
0
ファイル: Router.php プロジェクト: samlev/framework
 /**
  * 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}());
         }
     }
 }
コード例 #6
0
ファイル: Router.php プロジェクト: xel1045/laravel-module
 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;
 }
コード例 #7
0
 /**
  * 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;
 }
コード例 #8
0
ファイル: Router.php プロジェクト: janhartigan/framework
 /**
  * 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]));
         }
     }
 }
コード例 #9
0
 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');
 }
コード例 #10
0
ファイル: Route.php プロジェクト: themosis/framework
 /**
  * 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();
 }