Skip to content

Commit

Permalink
[console] Rollback ExtensionManager class. (#3581)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Nov 13, 2017
1 parent 511b99c commit 19359e6
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions src/Extension/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private function getExtensions(
$extensions[$name] = $extension;
}


return $nameOnly?array_keys($extensions):$extensions;
}

Expand All @@ -220,6 +221,11 @@ private function getExtensions(
*/
private function discoverExtensions($type)
{
if ($type === 'module') {
$this->site->loadLegacyFile('/core/modules/system/system.module');
system_rebuild_module_data();
}

if ($type === 'theme') {
$themeHandler = \Drupal::service('theme_handler');
$themeHandler->rebuildThemeData();
Expand All @@ -231,29 +237,8 @@ private function discoverExtensions($type)
*/
$discovery = new Discovery($this->appRoot);
$discovery->reset();
$extensions = $discovery->scan($type);

if ($type === 'module') {
// Using system_rebuild_module_data causes an error:
// Constructing service "logger.factory" from a parent definition is not supported at build time.
//$this->site->loadLegacyFile('/core/modules/system/system.module');
//system_rebuild_module_data();

// Looks that dependency on rebuild module data is just to determine
// the installed status so alternatively we can just look on installed
// modules config and apply to discovered extensions.
$installed_modules = \Drupal::config('core.extension')->get('module') ?: [];

/**
* @var \Drupal\Core\Extension\Extension $extension
*/
foreach ($extensions as $name => $extension) {
$extensions[$name]->weight = isset($installed_modules[$name]) ? $installed_modules[$name] : 0;
$extensions[$name]->status = (int) isset($installed_modules[$name]);
}
}

return $extensions;
return $discovery->scan($type);
}

/**
Expand Down Expand Up @@ -384,9 +369,9 @@ public function getDrupalExtension($type, $name)
public function checkExtensions(array $extensions, $type = 'module')
{
$checkextensions = [
'local_extensions' => [],
'drupal_extensions' => [],
'no_extensions' => [],
'local_extensions' => [],
'drupal_extensions' => [],
'no_extensions' => [],
];

$local_extensions = $this->discoverExtension($type)
Expand Down

0 comments on commit 19359e6

Please sign in to comment.