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


PHP Drupal::hasRequest方法代碼示例

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


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

示例1: __construct

 /**
  * Constructs a ThemeRegistry object.
  *
  * @param string $cid
  *   The cid for the array being cached.
  * @param \Drupal\Core\Cache\CacheBackendInterface $cache
  *   The cache backend.
  * @param \Drupal\Core\Lock\LockBackendInterface $lock
  *   The lock backend.
  * @param array $tags
  *   (optional) The tags to specify for the cache item.
  * @param bool $modules_loaded
  *   Whether all modules have already been loaded.
  */
 function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = array(), $modules_loaded = FALSE)
 {
     $this->cid = $cid;
     $this->cache = $cache;
     $this->lock = $lock;
     $this->tags = $tags;
     $this->persistable = $modules_loaded && \Drupal::hasRequest() && \Drupal::request()->isMethod('GET');
     // @todo: Implement lazyload.
     $this->cacheLoaded = TRUE;
     if ($this->persistable && ($cached = $this->cache->get($this->cid))) {
         $this->storage = $cached->data;
     } else {
         // If there is no runtime cache stored, fetch the full theme registry,
         // but then initialize each value to NULL. This allows offsetExists()
         // to function correctly on non-registered theme hooks without triggering
         // a call to resolveCacheMiss().
         $this->storage = $this->initializeRegistry();
         foreach (array_keys($this->storage) as $key) {
             $this->persist($key);
         }
         // RegistryTest::testRaceCondition() ensures that the cache entry is
         // written on the initial construction of the theme registry.
         $this->updateCache();
     }
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:39,代碼來源:ThemeRegistry.php

示例2: conf_path

 function conf_path($require_settings = TRUE, $reset = FALSE, Request $request = NULL)
 {
     if (!isset($request)) {
         if (\Drupal::hasRequest()) {
             $request = \Drupal::request();
         } else {
             $request = Request::createFromGlobals();
         }
     }
     if (\Drupal::hasService('kernel')) {
         $site_path = \Drupal::service('kernel')->getSitePath();
     }
     if (!isset($site_path) || empty($site_path)) {
         $site_path = DrupalKernel::findSitePath($request, $require_settings);
     }
     return $site_path;
 }
開發者ID:ankur325,項目名稱:drush,代碼行數:17,代碼來源:DrupalBoot8.php

示例3: getHostname

 /**
  * {@inheritdoc}
  */
 public function getHostname()
 {
     if (!isset($this->hostname) && \Drupal::hasRequest()) {
         $this->hostname = \Drupal::request()->getClientIp();
     }
     return $this->hostname;
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:10,代碼來源:User.php

示例4: __construct

 /**
  * Constructs a new anonymous user session.
  *
  * Intentionally don't allow parameters to be passed in like UserSession.
  */
 public function __construct()
 {
     if (\Drupal::hasRequest()) {
         $this->hostname = \Drupal::request()->getClientIp();
     }
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:11,代碼來源:AnonymousUserSession.php


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