本文整理汇总了PHP中Illuminate\Routing\Route::parameterNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::parameterNames方法的具体用法?PHP Route::parameterNames怎么用?PHP Route::parameterNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Route
的用法示例。
在下文中一共展示了Route::parameterNames方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
}
示例5: hasParameters
private function hasParameters(Route $route)
{
return count($route->parameterNames()) !== 0;
}
示例6: evaluateTemplated
/**
* @param Route $route
* @param UrlGenerator $urlGenerator
* @param $queryString
* @return bool
*/
private static function evaluateTemplated(Route $route, UrlGenerator $urlGenerator, $queryString)
{
// Does the route have named parameters? http://example.com/users/{users}
if (count($route->parameterNames())) {
return true;
}
$url = rawurldecode($urlGenerator->action($route->getActionName()));
// Does the route's URI already contain a query string? http://example.com/users?page={page}&per_page={per_page}
if (preg_match('/\\?.*=\\{.*?\\}/', $url)) {
return true;
}
// Does the query string contain any parameters?
if (preg_match('/\\?.*=\\{.*?\\}/', $queryString)) {
return true;
}
return false;
}