/** * 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); }
/** * 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; }
/** * @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]; }
/** * @see libraries_get_path() * * @param string $name * @param string|bool $base_path * * @return string|bool */ public function librariesGetPath($name, $base_path = FALSE) { $libraries =& $this->drupalStatic->get('libraries_get_path'); if (!isset($libraries)) { $libraries = $this->librariesGetLibraries(); } $path = $base_path ? base_path() : ''; if (!isset($libraries[$name])) { return FALSE; } else { $path .= $libraries[$name]; } return $path; }
/** * @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]); }