當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Router::currentRouteName方法代碼示例

本文整理匯總了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;
 }
開發者ID:realholgi,項目名稱:formobject,代碼行數:9,代碼來源:ResourceActionUrlProvider.php

示例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;
 }
開發者ID:atorscho,項目名稱:laravel-helpers,代碼行數:14,代碼來源:Assertions.php

示例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;
 }
開發者ID:nodes-php,項目名稱:backend,代碼行數:27,代碼來源:Router.php

示例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;
 }
開發者ID:shellofyou,項目名稱:laravel-boilerplate,代碼行數:26,代碼來源:Active.php

示例5: currentRouteName

 /**
  * Get the current route name.
  *
  * @return string|null 
  * @static 
  */
 public static function currentRouteName()
 {
     return \Illuminate\Routing\Router::currentRouteName();
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:10,代碼來源:_ide_helper.php

示例6: getBreadcrumbName

 /**
  * @return string
  */
 public function getBreadcrumbName()
 {
     return $this->breadcrumbName ?: $this->router->currentRouteName();
 }
開發者ID:shiruken1,項目名稱:laravel-dashboard,代碼行數:7,代碼來源:Dashboard.php

示例7: getFunctions

 /**
  * {@inheritDoc}
  */
 public function getFunctions() : array
 {
     return [new TwigSimpleFunction('route_name', function () {
         return str_replace('.', '-', $this->router->currentRouteName());
     }, ['is_safe' => ['html']])];
 }
開發者ID:thirteen,項目名稱:laravel-template,代碼行數:9,代碼來源:Route.php


注:本文中的Illuminate\Routing\Router::currentRouteName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。