/**
  * Scans and collects module .info data.
  *
  * @see _system_rebuild_module_data()
  *
  * @return object[]
  */
 public function systemBuildModuleData()
 {
     // Find modules
     $modules = $this->exampleModules->drupalSystemListingModules();
     if (FALSE) {
         // Include the installation profile in modules that are loaded.
         $profile = 'minimal';
         $modules[$profile] = new \stdClass();
         $modules[$profile]->name = $profile;
         $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile';
         $modules[$profile]->filename = $profile . '.profile';
         // Installation profile hooks are always executed last.
         $modules[$profile]->weight = 1000;
     } else {
         $profile = 'NO_PROFILE';
     }
     // Set defaults for module info.
     $defaults = array('dependencies' => array(), 'description' => '', 'package' => 'Other', 'version' => NULL, 'files' => array(), 'bootstrap' => 0);
     // Read info files for each module.
     foreach ($modules as $key => $module) {
         // The module system uses the key 'filename' instead of 'uri' so copy the
         // value so it will be used by the modules system.
         $modules[$key]->filename = $module->uri;
         // Look for the info file.
         $module->info = $this->exampleModules->drupalParseInfoFile($module->name);
         // Skip modules that don't provide info.
         if (empty($module->info)) {
             unset($modules[$key]);
             continue;
         }
         // Merge in defaults and save.
         $modules[$key]->info = $module->info + $defaults;
         // Installation profiles are hidden by default, unless explicitly specified
         // otherwise in the .info file.
         if ($key == $profile && !isset($modules[$key]->info['hidden'])) {
             $modules[$key]->info['hidden'] = TRUE;
         }
         // Invoke hook_system_info_alter() to give installed modules a chance to
         // modify the data in the .info files if necessary.
         $type = 'module';
         $this->hookSystem->drupalAlter('system_info', $modules[$key]->info, $modules[$key], $type);
     }
     if (isset($modules[$profile])) {
         // The installation profile is required, if it's a valid module.
         $modules[$profile]->info['required'] = TRUE;
         // Add a default distribution name if the profile did not provide one. This
         // matches the default value used in install_profile_info().
         if (!isset($modules[$profile]->info['distribution_name'])) {
             $modules[$profile]->info['distribution_name'] = 'Drupal';
         }
     }
     unset($modules['NO_PROFILE']);
     return $modules;
 }
Ejemplo n.º 2
0
 /**
  * @param string $hook
  * @param bool $sort
  *
  * @return array
  */
 private function discoverImplementations($hook, $sort)
 {
     # StaticCallLog::addCall();
     // The hook is not cached, so ensure that whether or not it has
     // implementations, that the cache is updated at the end of the request.
     $this->writeCache = TRUE;
     $hook_info = $this->moduleHookInfo();
     $implementations = array();
     $list = $this->moduleList->moduleList(FALSE, FALSE, $sort);
     if ('modules_enabled' === $hook) {
         # HackyLog::logx($list);
     }
     foreach ($list as $module) {
         $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
         // Since module_hook() may needlessly try to load the include file again,
         // function_exists() is used directly here.
         if (function_exists($module . '_' . $hook)) {
             $implementations[$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
         }
     }
     // Allow modules to change the weight of specific implementations but avoid
     // an infinite loop.
     if ($hook != 'module_implements_alter') {
         $this->hookSystem->drupalAlter('module_implements', $implementations, $hook);
     }
     return $implementations;
 }
Ejemplo n.º 3
0
 /**
  * @see libraries_info()
  *
  * @param string|null $name
  *
  * @return mixed
  */
 function &getLibrariesInfo($name = NULL)
 {
     // This static cache is re-used by libraries_detect() to save memory.
     $libraries =& $this->drupalStatic->get('libraries_info');
     if (!isset($libraries)) {
         $libraries = array();
         // Gather information from hook_libraries_info().
         foreach ($this->hookSystem->moduleImplements('libraries_info') as $module) {
             foreach (PureFunctions::moduleInvoke($module, 'libraries_info') as $machine_name => $properties) {
                 $properties['module'] = $module;
                 $libraries[$machine_name] = $properties;
             }
         }
         // Gather information from hook_libraries_info() in enabled themes.
         // @see drupal_alter()
         // SKIPPED
         // Gather information from .info files.
         // .info files override module definitions.
         // SKIPPED
         // Provide defaults.
         foreach ($libraries as $machine_name => &$properties) {
             $this->librariesInfoDefaults($properties, $machine_name);
         }
         // Allow modules to alter the registered libraries.
         $this->hookSystem->drupalAlter('libraries_info', $libraries);
         // Invoke callbacks in the 'info' group.
         // SKIPPED
     }
     if (isset($name)) {
         if (!empty($libraries[$name])) {
             return $libraries[$name];
         } else {
             $false = FALSE;
             return $false;
         }
     }
     return $libraries;
 }