本文整理匯總了PHP中Illuminate\Routing\UrlGenerator::route方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlGenerator::route方法的具體用法?PHP UrlGenerator::route怎麽用?PHP UrlGenerator::route使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Routing\UrlGenerator
的用法示例。
在下文中一共展示了UrlGenerator::route方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: compose
/**
* @param View $view
*/
public function compose(View $view)
{
$view->cruddyData = $this->cruddy->data();
$view->cruddyData += ['schemaUrl' => $this->url->route('cruddy.schema'), 'thumbUrl' => $this->url->route('cruddy.thumb'), 'baseUrl' => $this->url->route('cruddy.home'), 'root' => $this->request->root(), 'token' => csrf_token()];
$view->scripts = $this->assets->scripts();
$view->styles = $this->assets->styles();
$view->menu = $this->menuBuilder;
}
示例2: isPage
/**
* Return true if current page is $page.
*/
public function isPage(string $page, array $parameters = []) : bool
{
// Check if $page is a route name
if ($this->route->has($page)) {
if ($parameters) {
return $this->url->current() == $this->url->route($page, $parameters);
}
return $this->route->currentRouteName() == $page;
}
return str_replace($this->request->root() . '/', '', $this->url->full()) == $page;
}
示例3: renderHead
/**
* {@inheritdoc}
*/
public function renderHead()
{
if (!$this->url) {
return parent::renderHead();
}
$jsModified = $this->getModifiedTime('js');
$cssModified = $this->getModifiedTime('css');
$html = '';
$html .= sprintf('<link rel="stylesheet" type="text/css" href="%s?%s">' . "\n", $this->url->route('debugbar.assets.css'), $cssModified);
$html .= sprintf('<script type="text/javascript" src="%s?%s"></script>' . "\n", $this->url->route('debugbar.assets.js'), $jsModified);
if ($this->isJqueryNoConflictEnabled()) {
$html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n";
}
return $html;
}
示例4: renderHead
/**
* {@inheritdoc}
*/
public function renderHead()
{
if (!$this->url) {
return parent::renderHead();
}
$cssRoute = $this->url->route('debugbar.assets.css', ['v' => $this->getModifiedTime('css')]);
$jsRoute = $this->url->route('debugbar.assets.js', ['v' => $this->getModifiedTime('js')]);
$html = '';
$html .= "<link rel='stylesheet' type='text/css' href='{$cssRoute}'>";
$html .= "<script type='text/javascript' src='{$jsRoute}'></script>";
if ($this->isJqueryNoConflictEnabled()) {
$html .= '<script type="text/javascript">jQuery.noConflict(true);</script>' . "\n";
}
return $html;
}
示例5: action
/**
* Perform an API request to a controller action.
*
* @param string $action
* @param string|array $actionParameters
* @param string|array $parameters
* @return mixed
*/
public function action($action, $actionParameters = [], $parameters = [])
{
$version = $this->version ?: $this->router->getDefaultVersion();
$route = $this->router->getApiRouteCollection($version)->getByAction($action);
$uri = ltrim($this->url->route($action, $actionParameters, false, $route), '/');
return $this->queueRequest($route->methods()[0], $uri, $parameters);
}
示例6: url
/**
* Get a URL for a given page number.
*
* @param integer $page
* @return string
*/
public function url($page)
{
if (null === $this->routeConfig) {
//return parent::url($page);
if ($page <= 0) {
$page = 1;
}
// If we have any extra query string key / value pairs that need to be added
// onto the URL, we will put them in query string form and then attach it
// to the URL. This allows for extra information like sortings storage.
$parameters = [$this->pageName => $page];
if (count($this->query) > 0) {
$parameters = array_merge($this->query, $parameters);
}
return $this->getCurrentUrl() . '?' . http_build_query($parameters, null, '&') . $this->buildFragment();
}
$parameters = $this->routeConfig['parameters'];
//$parameters = [$this->pageName => $page];
//$this->getRequest()->query()
if (true === $this->withQuery) {
$parameters = array_merge($parameters, $this->query);
}
$parameters[$this->getPageName()] = $page;
$absolute = null === $this->routeConfig['absolute'] ? true : $this->routeConfig['absolute'];
// allow adding hash fragments to url
$fragment = $this->buildFragment();
$generated_route = $this->urlGenerator->route($this->routeConfig['name'], $parameters, $absolute, $this->routeConfig['instance']);
return $generated_route . $fragment;
}
示例7: getRoute
/**
* Get the route action for a "route" option.
*
* @param array|string $route
* @return string
*/
protected function getRoute($route)
{
if (is_array($route)) {
return $this->url->route($route[0], array_slice($route, 1));
}
return $this->url->route($route);
}
示例8: getRouteAction
/**
* Get the action for a "route" option.
*
* @param array|string $options
* @return string
*/
protected function getRouteAction($options)
{
if (is_array($options)) {
return $this->url->route($options[0], array_slice($options, 1));
}
return $this->url->route($options);
}
示例9: parseUrl
/**
* Return a named route if it exists.
*
* @param string $url
* @param array $parameters
*
* @return string
*/
protected function parseUrl($url, $parameters)
{
// If provided $url is a route name...
if ($this->route->has($url)) {
$url = $this->url->route($url, $parameters);
} else {
$url = $this->url->to($url, $parameters);
}
return $url;
}
示例10: route
/**
* Get the URL to a named route.
*
* @param string $name
* @param mixed $parameters
* @param bool $absolute
* @param \Illuminate\Routing\Route $route
* @return string
*
* @throws \InvalidArgumentException
*/
public function route($name, $parameters = array(), $absolute = true, $route = null)
{
if ($path = $this->getPathFinder()->toRouteName($name, $parameters)) {
if ($absolute) {
return $this->to($path);
}
return $path;
}
return parent::route($name, $parameters, $absolute, $route);
}
示例11: dispatch
/**
* Get the action type from the options.
*
* @param array $options
* @return string
*/
public function dispatch($options)
{
if (isset($options['url'])) {
return $this->getUrl($options);
} elseif (isset($options['route'])) {
return $this->url->route($options['route']);
} elseif (isset($options['action'])) {
return $this->url->action($options['action']);
}
return null;
}
示例12: getUrl
/**
* Get a URL for a given page number.
*
* @param integer $page
* @return string
*/
public function getUrl($page)
{
if (null === $this->routeConfig) {
return parent::getUrl($page);
}
$parameters = $this->routeConfig['parameters'];
if (true === $this->withQuery) {
$parameters = array_merge($parameters, $this->factory->getRequest()->query());
}
$parameters[$this->factory->getPageName()] = $page;
$absolute = null === $this->routeConfig['absolute'] ? true : $this->routeConfig['absolute'];
// allow adding hash fragments to url
$fragment = $this->buildFragment();
$generated_route = $this->urlGenerator->route($this->routeConfig['name'], $parameters, $absolute, $this->routeConfig['instance']);
return $generated_route . $fragment;
}
示例13: getAutologinLink
/**
* Get the link that can be used to automatically login a user to the
* application.
*
* @param \Illuminate\Auth\UserInterface $user
* @param string $path
* @return string
*/
protected function getAutologinLink(UserInterface $user, $path = null)
{
// If we are supposed to remove expired tokens, let's do it now.
if (config('autologin.remove_expired')) {
$this->deleteExpiredTokens();
}
// Get the user ID to be associated with a token.
$userId = $user->getAuthIdentifier();
// Generate a random unique token that can be used for the link.
$token = $this->getAutologinToken();
// Save the token to storage.
$this->provider->create(['user_id' => $userId, 'token' => $token, 'path' => $path]);
// Return a link using the route from the configuration file and
// the generated token.
$routeName = config('autologin.route_name');
return $this->generator->route($routeName, $token);
}
示例14: __call
/**
* @param string $method
* @param array $parameters
* @throws MethodNotFoundException
*/
public function __call($method, $parameters)
{
if (preg_match('/^routeTo(?<routeName>[a-zA-Z]+)$/', $method, $matches)) {
$route = Str::camel($matches['routeName']);
while (count($parameters) < 2) {
$parameters[] = [];
}
if (!is_array($parameters[1])) {
$parameters[1] = [$parameters[1]];
}
$routeParameters = $parameters[1];
array_unshift($routeParameters, $parameters[0]);
return $this->urlGenerator->route($this->routePrefix . '.table.' . $route, $routeParameters);
}
if (method_exists($this->laravelRouter, $method)) {
return $this->laravelRouter->group(['prefix' => $this->prefix, 'before' => $this->getBeforeFilters()], function () use($method, $parameters) {
call_user_func_array([$this->laravelRouter, $method], $parameters);
});
}
throw new MethodNotFoundException(get_class($this), $method);
}
示例15: generate
/**
* @todo - run this to ensure it generates the correct routes
* @param $name
* @param array $parameters
* @param $referenceType
* @return string
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
$refType = $referenceType === self::ABSOLUTE_PATH;
return $this->urlGenerator->route($name, $parameters, $refType);
}