本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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);
}
示例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}());
}
}
}
示例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;
}
示例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;
}
示例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]));
}
}
}
示例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');
}
示例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();
}