本文整理汇总了PHP中Illuminate\Routing\Router::currentRouteName方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::currentRouteName方法的具体用法?PHP Router::currentRouteName怎么用?PHP Router::currentRouteName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\Router
的用法示例。
在下文中一共展示了Router::currentRouteName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isResourceRoute
protected function isResourceRoute()
{
if ($routeName = $this->router->currentRouteName()) {
if (ends_with($routeName, ['.create', '.edit'])) {
return TRUE;
}
}
return FALSE;
}
示例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: alias
/**
* Match route by alias.
*
* @author Morten Rugaard <moru@nodes.dk>
*
* @param string|array $aliases
* @return string
*/
public function alias($aliases)
{
// Retrieve current request
$currentRoute = $this->router->current();
if (empty($currentRoute)) {
return $this->inactiveClass;
}
// Make sure patterns is an array
$aliases = !is_array($aliases) ? [$aliases] : $aliases;
// Current route's alias
$routeAlias = $this->router->currentRouteName();
// Check aliases and look for matches
foreach ($aliases as $alias) {
if ($routeAlias == $alias) {
return $this->activeClass;
}
}
return $this->inactiveClass;
}
示例4: routePattern
/**
* Check the current route name with one or some patterns
*
* @param string|array $patterns
* @param string $activeClass
* @param string $inactiveClass
*
* @return string the <code>$activeClass</code> if matched
* @since 1.2
*/
public function routePattern($patterns, $activeClass = 'active', $inactiveClass = '')
{
$routeName = $this->_router->currentRouteName();
if (!$routeName) {
return $inactiveClass;
}
if (!is_array($patterns)) {
$patterns = [$patterns];
}
foreach ($patterns as $p) {
if (str_is($p, $routeName)) {
return $activeClass;
}
}
return $inactiveClass;
}
示例5: currentRouteName
/**
* Get the current route name.
*
* @return string|null
* @static
*/
public static function currentRouteName()
{
return \Illuminate\Routing\Router::currentRouteName();
}
示例6: getBreadcrumbName
/**
* @return string
*/
public function getBreadcrumbName()
{
return $this->breadcrumbName ?: $this->router->currentRouteName();
}
示例7: getFunctions
/**
* {@inheritDoc}
*/
public function getFunctions() : array
{
return [new TwigSimpleFunction('route_name', function () {
return str_replace('.', '-', $this->router->currentRouteName());
}, ['is_safe' => ['html']])];
}