currentRouteName() 공개 메소드

Get the current route name.
public currentRouteName ( ) : string | null
리턴 string | null
 protected function isResourceRoute()
 {
     if ($routeName = $this->router->currentRouteName()) {
         if (ends_with($routeName, ['.create', '.edit'])) {
             return TRUE;
         }
     }
     return FALSE;
 }
예제 #2
0
 /**
  * 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
0
 /**
  * Match route by alias.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @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
0
 /**
  * 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
0
 /**
  * Get the current route name.
  *
  * @return string|null 
  * @static 
  */
 public static function currentRouteName()
 {
     return \Illuminate\Routing\Router::currentRouteName();
 }
예제 #6
0
 /**
  * @return string
  */
 public function getBreadcrumbName()
 {
     return $this->breadcrumbName ?: $this->router->currentRouteName();
 }
예제 #7
0
 /**
  * {@inheritDoc}
  */
 public function getFunctions() : array
 {
     return [new TwigSimpleFunction('route_name', function () {
         return str_replace('.', '-', $this->router->currentRouteName());
     }, ['is_safe' => ['html']])];
 }