本文整理汇总了PHP中Illuminate\Routing\UrlGenerator::current方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlGenerator::current方法的具体用法?PHP UrlGenerator::current怎么用?PHP UrlGenerator::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\UrlGenerator
的用法示例。
在下文中一共展示了UrlGenerator::current方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: url
/**
* Generates a url for Sorter
*
* @param string $field
* @param null|string $path
* @param boolean $appends
* */
public function url($field, $path = null, $appends = true)
{
if ($path === null) {
$path = $this->url->current();
}
$queryString = [$this->getFieldIndex() => $field, $this->getDirectionIndex() => $this->getConditionallyDirection($field)];
$appends && ($queryString += $this->request->query());
$url = $path . '?' . http_build_query($queryString);
return $this->url->to($url);
}
示例2: calculateFullPath
/**
* @param array $value
* @param string $route
* @param UrlGenerator $router
*
* @return mixed|string
*/
protected function calculateFullPath(array &$value, $route, UrlGenerator $router)
{
if (!empty($value['as_id'])) {
preg_match_all('/{(.*?)}/', $route, $matches);
$route = str_replace($matches[0], '{' . $value['as_id'] . '}', $route);
}
$port = parse_url($router->current(), PHP_URL_PORT);
$port = null == $port ? '' : ':' . $port;
$scheme = parse_url($router->current(), PHP_URL_SCHEME);
$host = parse_url($router->current(), PHP_URL_HOST) . $port;
return sprintf('%s://%s/%s', $scheme, $host, $route);
}
示例3: 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;
}
示例4: itemShouldBeActive
/**
* @param $link
* @return bool
*/
private function itemShouldBeActive($link)
{
if (is_string($link)) {
return false;
}
$auto = $this->autoroute && $this->url->current() == $link['link'];
$manual = isset($link['active']) && $link['active'];
return $auto || $manual;
}
示例5: getAction
/**
* Get the form action from the options.
*
* @param array $options
* @return string
*/
protected function getAction(array $options)
{
// We will also check for a "route" or "action" parameter on the array so that
// developers can easily specify a route or controller action when creating
// a form providing a convenient interface for creating the form actions.
if (isset($options['url'])) {
return $this->getUrlAction($options['url']);
}
if (isset($options['route'])) {
return $this->getRouteAction($options['route']);
} elseif (isset($options['action'])) {
return $this->getControllerAction($options['action']);
}
return $this->url->current();
}
示例6: getAction
/**
* Get the form action from the options.
*
* @param array $options
*
* @return string
*/
protected function getAction(array $options)
{
// We will also check for a "route" or "action" parameter on the array so that
// developers can easily specify a route or controller action when creating
// a form providing a convenient interface for creating the form actions.
if (isset($options['url'])) {
return $this->getUrlAction($options['url']);
}
// If an action is available, we are attempting to open a form to a controller
// action route. So, we will use the URL generator to get the path to these
// actions and return them from the method. Otherwise, we'll use current.
if (isset($options['route'])) {
return $this->getRouteAction($options['route']);
} elseif (isset($options['action'])) {
return $this->getControllerAction($options['action']);
}
return $this->url->current();
}
示例7: current
/**
* Get the current URL for the request.
*
* @return string
* @static
*/
public static function current()
{
return \Illuminate\Routing\UrlGenerator::current();
}
示例8: getCurrentUrl
/**
* @inheritdoc
*/
public function getCurrentUrl()
{
return $this->url->current();
}
示例9:
function it_implements_routes_with_dynamic_parameters(UrlGenerator $url)
{
// Having
$user_id = 20;
$year = 2015;
$month = 07;
$day = 11;
$account = "http://example.com/account/{$user_id}";
$calendar = "http://example.com/calendar/{$year}/{$month}/{$day}";
$url->current()->shouldBeCalled()->willReturn($account);
$url->to('')->shouldBeCalled()->willReturn('http://example/');
$url->route('account', [$user_id])->shouldBeCalled()->willReturn($account);
$url->route('calendar', [$year, $month, $day])->shouldBeCalled()->willReturn($calendar);
// Generate new menu
$menu = $this->make(['account' => ['route' => ['account', ':user_id']], 'calendar' => ['route' => ['calendar', ':year', ':month', ':day']]]);
// With dynamic parameters
$menu->setParams(compact('year', 'month', 'day'));
$menu->setParam('user_id', $user_id);
$items = ['account' => ['class' => 'active', 'submenu' => null, 'id' => 'account', 'active' => true, 'title' => 'Account', 'url' => $account], 'calendar' => ['class' => '', 'submenu' => null, 'id' => 'calendar', 'active' => false, 'title' => 'Calendar', 'url' => $calendar]];
$menu->getItems()->shouldReturn($items);
}
示例10: let
function let(UrlGenerator $url)
{
$url->current()->willReturn('link');
$this->beConstructedWith($url);
}
示例11: urlOrCurrent
private function urlOrCurrent($url = null)
{
return $url === null ? $this->urlGenerator->current() : $url;
}
示例12: isActive
/**
* Return true if current breadcrumb item is active.
*
* @return bool
*/
public function isActive()
{
return $this->url == $this->routing->current();
}
示例13: addCurrent
/**
* Add current page to the breadcrumbs array.
*
* @param string $title
*
* @return $this
*/
public function addCurrent($title)
{
return $this->add($this->url->current(), $title);
}