Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency injection container to Drush. #2018

Merged
merged 19 commits into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a7162ba
Add dependency injection container to Drush.
greg-1-anderson Dec 24, 2015
9f71028
Set appropriate versions for symfony/dependency-injection components.
greg-1-anderson Dec 24, 2015
68d21e0
Add a 'Drush' class to hold the DI container and serve as an interfac…
greg-1-anderson Dec 27, 2015
2fa3f1c
Initialize bootstrap objects via dependency injection.
greg-1-anderson Dec 28, 2015
fb3d82e
Add missing 'use' statements to define namespace for LoggerInterface.
greg-1-anderson Dec 28, 2015
4931c45
Remove functions from bootstrap.inc that have already been moved to t…
greg-1-anderson Dec 28, 2015
6658462
Add comments to services file.
greg-1-anderson Dec 28, 2015
b61f44d
Remove unnecessary comments.
greg-1-anderson Dec 28, 2015
7ffeef5
Rather than name all of the boot classes in the BootstrapManager, tag…
greg-1-anderson Dec 28, 2015
93c8189
Add missing static keyword.
greg-1-anderson Dec 28, 2015
debd122
Don't compile the DI container yet.
greg-1-anderson Dec 29, 2015
ba799ea
Add missing 'public static' to addBootstrapManagerReferences() method.
greg-1-anderson Dec 29, 2015
33cfeb0
Make our dependency injection container match Drupal 8's version.
greg-1-anderson Feb 22, 2016
ea425dc
Rename getBootstrap to just bootstrap.
greg-1-anderson Mar 8, 2016
e955c91
Rename a couple of missed calls to getBootstrap to bootstrap.
greg-1-anderson Mar 8, 2016
43fea38
Go back to Symfony/dependency-injection 2.7.6 for now.
greg-1-anderson Mar 8, 2016
2be9d13
Pin symfony components to 2.8.2 -- pretend that Drupal 8.1.x is all t…
greg-1-anderson Mar 8, 2016
34a073e
Actually, we are primarily using Drupal 8.0.x in tests. Back to Symfo…
greg-1-anderson Mar 8, 2016
94cbdf6
Try using league/container for our Dependency Injection container.
greg-1-anderson Mar 9, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/core/cli.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function drush_cli_core_cli() {
// command in preflight still, but the subscriber instances are already
// created from before. Call terminate() regardless, this is a no-op for all
// DrupalBoot classes except DrupalBoot8.
if ($bootstrap = drush_get_bootstrap_object()) {
if ($bootstrap = \Drush::bootstrap()) {
$bootstrap->terminate();
}

Expand Down
16 changes: 8 additions & 8 deletions commands/core/core.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ function _core_site_credentials($right_margin = 0) {
function _core_path_aliases($project = '') {
$paths = array();
$site_wide = drush_drupal_sitewide_directory();
$boot = drush_get_bootstrap_object();
$boot = \Drush::bootstrap();
if ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT')) {
$paths['%root'] = $drupal_root;
if ($site_root = drush_get_context('DRUSH_DRUPAL_SITE_ROOT')) {
Expand Down Expand Up @@ -564,7 +564,7 @@ function _core_site_status_table($project = '') {
$phase = drush_get_context('DRUSH_BOOTSTRAP_PHASE');
if ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT')) {
$status_table['drupal-version'] = drush_drupal_version();
$boot_object = drush_get_bootstrap_object();
$boot_object = \Drush::bootstrap();
$conf_dir = $boot_object->conf_path();
$settings_file = "$conf_dir/settings.php";
$status_table['drupal-settings-file'] = file_exists($settings_file) ? $settings_file : '';
Expand Down Expand Up @@ -890,7 +890,7 @@ function drush_core_quick_drupal() {
drush_set_option('backend', TRUE);
drush_set_option('strict', FALSE); // We fail option validation because do so much internal drush_invoke().
$makefile = drush_get_option('makefile');
$root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
$root = \Drush::bootstrapManager()->getRoot();
if (drush_get_option('use-existing', ($root != FALSE))) {
if (!$root) {
return drush_set_error('QUICK_DRUPAL_NO_ROOT_SPECIFIED', 'Must specify site with --root when using --use-existing.');
Expand Down Expand Up @@ -947,9 +947,9 @@ function drush_core_quick_drupal() {
drush_set_option('db-url', 'sqlite://' . $base . '/sites/' . strtolower(drush_get_option('sites-subdir', 'default')) . "/$name.sqlite");
}
// We have just created a site root where one did not exist before.
// We therefore must manually reset DRUSH_SELECTED_DRUPAL_ROOT to
// We therefore must manually reset the selected root to
// our new root, and force a bootstrap to DRUSH_BOOTSTRAP_DRUPAL_ROOT.
drush_set_context('DRUSH_SELECTED_DRUPAL_ROOT', $root);
\Drush::bootstrapManager()->setRoot($root);
if (!drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_ROOT)) {
return drush_set_error('QUICK_DRUPAL_ROOT_LOCATE_FAIL', 'Unable to locate Drupal root directory.');
}
Expand Down Expand Up @@ -990,7 +990,7 @@ function drush_core_quick_drupal() {
// Current CLI user is also the web server user, which is for development
// only. Hence we can safely make the site directory writable. This makes
// it easier to delete and edit settings.php.
$boot = drush_get_bootstrap_object();
$boot = \Drush::bootstrap();
@chmod($boot->conf_path(), 0700);
drush_invoke_process(array('root' => $root, 'uri' => $server_uri), 'runserver', array($server));
}
Expand Down Expand Up @@ -1306,7 +1306,7 @@ function drush_core_execute() {
$cmd = implode(' ', $args);
// If we selected a Drupal site, then cwd to the site root prior to exec
$cwd = FALSE;
if ($selected_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT')) {
if ($selected_root = \Drush::bootstrapManager()->getRoot()) {
if (is_dir($selected_root)) {
$cwd = getcwd();
drush_op('chdir', $selected_root);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ function drush_core_twig_compile() {
require_once DRUSH_DRUPAL_CORE . "/themes/engines/twig/twig.engine";
// Scan all enabled modules and themes.
// @todo Refactor to not reuse commandfile paths directly.
$boot = drush_get_bootstrap_object();
$boot = \Drush::bootstrap();
$searchpaths = $boot->commandfile_searchpaths(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$searchpaths[] = drupal_get_path('theme', drush_theme_get_default());;
$searchpaths[] = drupal_get_path('theme', drush_theme_get_admin());
Expand Down
6 changes: 3 additions & 3 deletions commands/core/drupal/environment.inc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function drush_module_enable($modules) {
drush_module_install($modules);

// Our logger got blown away during the container rebuild above.
$boot = drush_select_bootstrap_class();
$boot = \Drush::bootstrapManager()->bootstrap();
$boot->add_logger();

// Flush all caches. No longer needed in D8 per https://github.com/drush-ops/drush/issues/1207
Expand Down Expand Up @@ -226,7 +226,7 @@ function drush_module_disable($modules) {
function drush_module_uninstall($modules) {
\Drupal::service('module_installer')->uninstall($modules);
// Our logger got blown away during the container rebuild above.
$boot = drush_select_bootstrap_class();
$boot = \Drush::bootstrapManager()->bootstrap();
$boot->add_logger();
}

Expand Down Expand Up @@ -319,7 +319,7 @@ function drush_theme_disable($themes) {
function drush_theme_uninstall($themes) {
\Drupal::service('theme_handler')->uninstall($themes);
// Our logger got blown away during the container rebuild above.
$boot = drush_select_bootstrap_class();
$boot = \Drush::bootstrapManager()->bootstrap();
$boot->add_logger();
}

Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"psy/psysh": "~0.6",
"symfony/yaml": "~2.3|~3.0",
"symfony/var-dumper": "~2.7|~3.0",
"league/container": "~2",
"symfony/config": "~2.2",
"pear/console_table": "~1.3.0"
},
"require-dev": {
Expand All @@ -47,7 +49,10 @@
"autoload": {
"psr-0": {
"Drush": "lib/"
}
},
"files": [
"lib/Drush.php"
]
},
"autoload-dev": {
"psr-0": {
Expand Down
Loading