Beispiel #1
0
 /**
  * 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();
     }
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function getHostname()
 {
     if (!isset($this->hostname) && \Drupal::hasRequest()) {
         $this->hostname = \Drupal::request()->getClientIp();
     }
     return $this->hostname;
 }
 /**
  * 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();
     }
 }