/**
  * @see system_list()
  *
  * @return array[]
  */
 public function loadSystemLists()
 {
     $lists = array('module_enabled' => array(), 'theme' => array(), 'filepaths' => array());
     // The module name (rather than the filename) is used as the fallback
     // weighting in order to guarantee consistent behavior across different
     // Drupal installations, which might have modules installed in different
     // locations in the file system. The ordering here must also be
     // consistent with the one used in module_implements().
     foreach ($this->systemTable->systemTableSortedObjects() as $record) {
         // Build a list of all enabled modules.
         if ($record->type == 'module') {
             if (1 != $record->status) {
                 continue;
             }
             $lists['module_enabled'][$record->name] = $record;
         } elseif ($record->type == 'theme') {
             $lists['theme'][$record->name] = $record;
         } else {
             continue;
         }
         // Build a list of filenames so drupal_get_filename can use it.
         if ($record->status) {
             $lists['filepaths'][] = array('type' => $record->type, 'name' => $record->name, 'filepath' => $record->filename);
         }
     }
     $this->themesAddHierarchy($lists['theme']);
     return $lists;
 }
 /**
  * @see system_update_files_database()
  *
  * @param object[] $files
  * @param string $type
  */
 private function systemUpdateFilesDatabase($files, $type)
 {
     $this->systemTable->systemUpdateFilesDatabase($files, $type);
     // If any module or theme was moved to a new location, we need to reset the
     // system_list() cache or we will continue to load the old copy, look for
     // schema updates in the wrong place, etc.
     $this->systemListReset->systemListReset();
 }
 /**
  * @see _system_update_bootstrap_status()
  */
 function systemUpdateBootstrapStatus()
 {
     $bootstrap_modules = array();
     foreach (PureFunctions::bootstrapHooks() as $hook) {
         foreach ($this->hookSystem->moduleImplements($hook) as $module) {
             $bootstrap_modules[$module] = TRUE;
         }
     }
     $this->systemTable->setBootstrapModules($bootstrap_modules);
     // Reset the cached list of bootstrap modules.
     $this->systemListReset->systemListReset();
 }
 /**
  * Replicates drupal_get_filename(*, *, NULL)
  *
  * @param string $type
  * @param string $name
  *
  * @return string|null
  */
 function drupalGetFilename($type, $name)
 {
     // Profiles are a special case: they have a fixed location and naming.
     if ($type == 'profile') {
         $profile_filename = "profiles/{$name}/{$name}.profile";
         $this->files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
     }
     // Look in runtime cache.
     if (isset($this->files[$type][$name])) {
         return $this->files[$type][$name];
     }
     // Load from the database.
     $file = $this->systemTable->moduleGetFilename($name);
     if (isset($file) && file_exists($file)) {
         $this->files[$type][$name] = $file;
         return $file;
     }
     // Fallback: Search the filesystem.
     $this->files[$type] = $this->exampleModules->discoverModuleFilenames($type);
     if (isset($this->files[$type][$name])) {
         return $this->files[$type][$name];
     }
     return NULL;
 }
Example #5
0
 public function needleGroupProvider()
 {
     $randomcase = function (&$string) {
         $chars = str_split($string);
         array_walk($chars, function (&$char) {
             rand(0, 1) ? $char = strtoupper($char) : ($char = strtolower($char));
         });
         return implode('', $chars);
     };
     $data = [];
     foreach (SystemTable::getMap() as $group => $systems) {
         $data[] = [$group, $group];
         foreach ($systems as $system) {
             $data[] = [ucfirst($system), $group];
             $data[] = [$randomcase($system), $group];
         }
     }
     return $data;
 }
Example #6
0
 /**
  * @param string $extension
  * @param bool $install
  *
  * @see module_enable()
  */
 private function enableModule($extension, $install)
 {
     $filename = $this->drupalGetFilename->drupalGetFilename('module', $extension);
     // Include module files.
     require_once $filename;
     if (file_exists($install_file = dirname($filename) . '/' . $extension . '.install')) {
         require_once $install_file;
     }
     // Update status in system table
     $this->systemTable->moduleSetEnabled($extension);
     // Clear various caches, especially hook_module_implements()
     $this->systemListReset->systemListReset();
     $this->moduleList->moduleList(TRUE);
     $this->hookSystem->moduleImplementsReset();
     $this->systemUpdateBootstrapStatus->systemUpdateBootstrapStatus();
     // Update the registry to include it.
     # registry_update();
     // Refresh the schema to include it.
     # drupal_get_schema(NULL, TRUE);
     // Update the theme registry to include it.
     # drupal_theme_rebuild();
     // Clear entity cache.
     # entity_info_cache_clear();
     if ($install) {
         PureFunctions::moduleInvoke($extension, 'schema');
         $this->systemTable->moduleSetSchemaVersion($extension, 7000);
         PureFunctions::moduleInvoke($extension, 'update_last_removed');
         // Optional hook_install()..
         PureFunctions::moduleInvoke($extension, 'install');
         // Optional watchdog()
         $this->hookSystem->moduleInvokeAll('watchdog');
     }
     // hook_enable()
     PureFunctions::moduleInvoke($extension, 'enable');
     // watchdog()
     $this->hookSystem->moduleInvokeAll('watchdog');
 }