Пример #1
0
 /**
  * Replicates module_list($refresh, $bootstrap_refresh, $sort, NULL)
  *
  * @see module_list()
  *
  * @param bool $refresh
  * @param bool $bootstrap_refresh
  * @param bool $sort
  *
  * @return string[]
  */
 function moduleList($refresh = FALSE, $bootstrap_refresh = FALSE, $sort = FALSE)
 {
     if (empty($this->list) || $refresh) {
         $this->list = array();
         $sorted_list = NULL;
         if ($refresh) {
             // For the $refresh case, make sure that system_list() returns fresh
             // data.
             $this->drupalStatic->resetKey('system_list');
         }
         if ($bootstrap_refresh) {
             $this->list = $this->systemList->systemListBootstrap();
         } else {
             // Not using drupal_map_assoc() here as that requires common.inc.
             $this->list = array_keys($this->systemList->systemListModuleEnabled());
             $this->list = !empty($this->list) ? array_combine($this->list, $this->list) : array();
         }
     }
     if ($sort) {
         return $this->moduleListSorted();
     }
     if (count($this->list)) {
         # HackyLog::log($this->list);
     }
     return $this->list;
 }
Пример #2
0
 /**
  * Replicates system_list('bootstrap')
  *
  * @see system_list()
  *
  * @return array|null
  */
 function systemListBootstrap()
 {
     $lists =& $this->drupalStatic->get('system_list');
     // For bootstrap modules, attempt to fetch the list from cache if possible.
     // if not fetch only the required information to fire bootstrap hooks
     // in case we are going to serve the page from cache.
     if (isset($lists['bootstrap'])) {
         return $lists['bootstrap'];
     }
     if ($cached = $this->cache->cacheGet('bootstrap_modules', 'cache_bootstrap')) {
         $bootstrap_list = $cached->data;
     } else {
         $bootstrap_list = $this->systemListLoader->fetchBootstrapSystemList();
         $this->cache->cacheSet('bootstrap_modules', $bootstrap_list, 'cache_bootstrap');
     }
     // To avoid a separate database lookup for the filepath, prime the
     // drupal_get_filename() static cache for bootstrap modules only.
     // The rest is stored separately to keep the bootstrap module cache small.
     foreach ($bootstrap_list as $module) {
         $this->drupalGetFilename->drupalSetFilename('module', $module->name, $module->filename);
     }
     // We only return the module names here since module_list() doesn't need
     // the filename itself.
     return $lists['bootstrap'] = array_keys($bootstrap_list);
 }
Пример #3
0
 /**
  * @see system_list_reset()
  */
 function systemListReset()
 {
     $this->drupalStatic->resetKey('system_list');
     $this->drupalStatic->resetKey('system_rebuild_module_data');
     $this->drupalStatic->resetKey('list_themes');
     $this->cache->cacheClearAll('bootstrap_modules', 'cache_bootstrap');
     $this->cache->cacheClearAll('system_list', 'cache_bootstrap');
 }
 /**
  * Rebuild, save, and return data about all currently available modules.
  *
  * @see system_rebuild_module_data()
  *
  * @return array[]
  */
 public function systemRebuildModuleData()
 {
     $modules_cache =& $this->drupalStatic->get('system_rebuild_module_data');
     // Only rebuild once per request. $modules and $modules_cache cannot be
     // combined into one variable, because the $modules_cache variable is reset by
     // reference from system_list_reset() during the rebuild.
     if (!isset($modules_cache)) {
         $modules = $this->systemBuildModuleData->systemBuildModuleData();
         ksort($modules);
         $this->systemTable->systemGetFilesDatabase($modules, 'module');
         $this->systemUpdateFilesDatabase($modules, 'module');
         $modules = $this->moduleBuildDependencies->moduleBuildDependencies($modules);
         $modules_cache = $modules;
     }
     return $modules_cache;
 }
Пример #5
0
 /**
  * @param string $name
  *
  * @see libraries_load()
  */
 function librariesLoad($name)
 {
     $loaded =& $this->drupalStatic->get('libraries_load', array());
     if (!isset($loaded[$name])) {
         $library = $this->cache->cacheGet($name, 'cache_libraries');
         if ($library) {
             $library = $library->data;
         } else {
             $library = $this->librariesDetect($name);
             $this->cache->cacheSet($name, $library, 'cache_libraries');
         }
         // If a variant was specified, override the top-level properties with the
         // variant properties.
         if (isset($variant)) {
             // Ensure that the $variant key exists, and if it does not, set its
             // 'installed' property to FALSE by default. This will prevent the loading
             // of the library files below.
             $library['variants'] += array($variant => array('installed' => FALSE));
             $library = array_merge($library, $library['variants'][$variant]);
         }
         // Regardless of whether a specific variant was requested or not, there can
         // only be one variant of a library within a single request.
         unset($library['variants']);
         // Invoke callbacks in the 'pre-dependencies-load' group.
         $this->librariesInvoke('pre-dependencies-load', $library);
         // If the library (variant) is installed, load it.
         $library['loaded'] = FALSE;
         if ($library['installed']) {
             // Load library dependencies.
             if (isset($library['dependencies'])) {
                 foreach ($library['dependencies'] as $dependency) {
                     $this->librariesLoad($dependency);
                 }
             }
             // Invoke callbacks in the 'pre-load' group.
             $this->librariesInvoke('pre-load', $library);
             // Load all the files associated with the library.
             $library['loaded'] = $this->librariesLoadFiles($library);
             // Invoke callbacks in the 'post-load' group.
             $this->librariesInvoke('post-load', $library);
         }
         $loaded[$name] = $library;
     }
     return $loaded[$name];
 }
Пример #6
0
 /**
  * @see module_implements()
  *
  * @param string $hook
  * @param bool $sort
  *
  * @return array
  */
 function moduleImplements($hook, $sort = FALSE)
 {
     // Use the advanced drupal_static() pattern, since this is called very often.
     if (!isset($this->drupalStaticFast)) {
         $this->drupalStaticFast['implementations'] =& $this->drupalStatic->get('module_implements');
     }
     $implementations =& $this->drupalStaticFast['implementations'];
     // Fetch implementations from cache.
     if (empty($implementations)) {
         $cache = $this->cache->cacheGet('module_implements', 'cache_bootstrap');
         if (FALSE === $cache) {
             $implementations = array();
         } else {
             $implementations = $cache->data;
         }
     }
     if (!isset($implementations[$hook])) {
         $implementations[$hook] = $this->discoverImplementations($hook, $sort);
     } else {
         // @todo Change this when https://drupal.org/node/2263365 has landed in Drupal core.
         $this->filterImplementations($implementations[$hook], $hook);
     }
     return array_keys($implementations[$hook]);
 }
Пример #7
0
 public function resetLibrariesInfo()
 {
     $this->drupalStatic->resetKey('libraries_info');
 }