Skip to content

Commit

Permalink
Add composer extend plugin. (#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Feb 9, 2017
1 parent ca15412 commit c6d9d17
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 296 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"require": {
"php": "^5.5.9 || ^7.0",
"drupal/console-core" : "1.0.0-rc15",
"drupal/console-extend-plugin": "~0",
"alchemy/zippy": "0.4.3",
"doctrine/collections":"1.3.0",
"composer/installers": "~1.0",
Expand Down
43 changes: 42 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ services:
console.annotation_validator:
class: Drupal\Console\Utils\AnnotationValidator
arguments: ['@console.annotation_command_reader', '@console.extension_manager']
console.extend_extension_manager:
class: Drupal\Console\Utils\ExtendExtensionManager
45 changes: 11 additions & 34 deletions src/Bootstrap/AddServicesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Yaml\Yaml;
use Drupal\Console\Utils\ExtendExtensionManager;
use Drupal\Console\Utils\TranslatorManager;
use Drupal\Console\Extension\Extension;
use Drupal\Console\Extension\Manager;
Expand Down Expand Up @@ -65,17 +64,15 @@ public function process(ContainerBuilder $container)
->loadConfiguration($this->root)
->getConfiguration();

$basePath = $container->get('console.site')->getCacheDirectory();
$consoleServicesFile = $basePath.'/console.services.yml';
$consoleExtendServicesFile = $basePath.'/extend.console.services.yml';
$consoleExtendConfigFile = $basePath.'/extend.console.config.yml';
$cacheDirectory = $container->get('console.site')->getCacheDirectory();
$consoleServicesFile = $cacheDirectory.'/console.services.yml';

if ($basePath && !$this->rebuild && file_exists($consoleServicesFile)) {
if (!$this->rebuild && file_exists($consoleServicesFile)) {
$loader->load($consoleServicesFile);
if (file_exists($consoleExtendServicesFile)) {
$loader->load($consoleExtendServicesFile);
}
} else {
if (file_exists($consoleServicesFile)) {
unlink($consoleServicesFile);
}
$finder = new Finder();
$finder->files()
->name('*.yml')
Expand Down Expand Up @@ -152,37 +149,17 @@ public function process(ContainerBuilder $container)
}
}

if ($servicesData && is_writable($basePath)) {
if ($servicesData && is_writable($cacheDirectory)) {
file_put_contents(
$consoleServicesFile,
Yaml::dump($servicesData, 4, 2)
);
}
}

/**
* @var ExtendExtensionManager $extendExtensionManager
*/
$extendExtensionManager = $container->get('console.extend_extension_manager');
$extendExtensionManager->processProjectPackages($this->root);
$configData = $extendExtensionManager->getConfigData();
if ($configData && is_writable($basePath)) {
file_put_contents(
$consoleExtendConfigFile,
Yaml::dump($configData, 6, 2)
);
}
$servicesData = $extendExtensionManager->getServicesData();
if ($servicesData && is_writable($basePath)) {
file_put_contents(
$consoleExtendServicesFile,
Yaml::dump($servicesData, 4, 2)
);
}

$servicesFiles = $extendExtensionManager->getServicesFiles();
foreach ($servicesFiles as $servicesFile) {
$loader->load($servicesFile);
}
$consoleExtendServicesFile = $this->root. DRUPAL_CONSOLE .'/extend.console.services.yml';
if (file_exists($consoleExtendServicesFile)) {
$loader->load($consoleExtendServicesFile);
}

$configurationManager = $container->get('console.configuration_manager');
Expand Down
20 changes: 2 additions & 18 deletions src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,10 @@ public function boot($debug)
$this->root
);

$basePath = $container->get('console.site')->getCacheDirectory();
$consoleExtendConfigFile = $basePath.'/extend.console.config.yml';

if ($basePath && file_exists($consoleExtendConfigFile)) {
$consoleExtendConfigFile = $this->root . DRUPAL_CONSOLE .'/extend.console.config.yml';
if (file_exists($consoleExtendConfigFile)) {
$container->get('console.configuration_manager')
->importConfigurationFile($consoleExtendConfigFile);
} else {
/**
* @var ExtendExtensionManager $extendExtensionManager
*/
$extendExtensionManager = $container->get('console.extend_extension_manager');
if (!$extendExtensionManager->isProcessed()) {
$extendExtensionManager->processProjectPackages($this->root);
}
$configFiles = $extendExtensionManager->getConfigFiles();

foreach ($configFiles as $configFile) {
$container->get('console.configuration_manager')
->importConfigurationFile($configFile);
}
}

$container->get('console.renderer')
Expand Down
Loading

0 comments on commit c6d9d17

Please sign in to comment.