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


PHP RouteProviderInterface::preLoadRoutes方法代碼示例

本文整理匯總了PHP中Drupal\Core\Routing\RouteProviderInterface::preLoadRoutes方法的典型用法代碼示例。如果您正苦於以下問題:PHP RouteProviderInterface::preLoadRoutes方法的具體用法?PHP RouteProviderInterface::preLoadRoutes怎麽用?PHP RouteProviderInterface::preLoadRoutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Routing\RouteProviderInterface的用法示例。


在下文中一共展示了RouteProviderInterface::preLoadRoutes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onRequest

 /**
  * Loads all non-admin routes right before the actual page is rendered.
  *
  * @param \Symfony\Component\HttpKernel\Event\KernelEvent $event
  *   The event to process.
  */
 public function onRequest(KernelEvent $event)
 {
     // Only preload on normal HTML pages, as they will display menu links.
     if ($this->routeProvider instanceof PreloadableRouteProviderInterface && $event->getRequest()->getRequestFormat() == 'html') {
         if ($routes = $this->state->get('routing.non_admin_routes', [])) {
             // Preload all the non-admin routes at once.
             $this->routeProvider->preLoadRoutes($routes);
         }
     }
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:16,代碼來源:RoutePreloader.php

示例2: onRequest

 /**
  * Loads all non-admin routes right before the actual page is rendered.
  *
  * @param \Symfony\Component\HttpKernel\Event\KernelEvent $event
  *   The event to process.
  */
 public function onRequest(KernelEvent $event)
 {
     // Only preload on normal HTML pages, as they will display menu links.
     if ($this->routeProvider instanceof PreloadableRouteProviderInterface && $event->getRequest()->getRequestFormat() == 'html') {
         // Ensure that the state query is cached to skip the database query, if
         // possible.
         $key = 'routing.non_admin_routes';
         if ($cache = $this->cache->get($key)) {
             $routes = $cache->data;
         } else {
             $routes = $this->state->get($key, []);
             $this->cache->set($key, $routes, Cache::PERMANENT, ['routes']);
         }
         if ($routes) {
             // Preload all the non-admin routes at once.
             $this->routeProvider->preLoadRoutes($routes);
         }
     }
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:25,代碼來源:RoutePreloader.php


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