From 269b4b487d002eafe644180abcd8a3279b154f9f Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Tue, 26 Oct 2021 12:15:14 +0300 Subject: [PATCH] EWPP-1165: Reorganise code for adapting drush site-install arguments. --- config/runner.yml | 10 ++++------ src/Commands/AbstractDrupalCommands.php | 10 +++++----- src/Tasks/Drush/Drush.php | 17 +++++++++-------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/config/runner.yml b/config/runner.yml index cf86f71..921b10d 100644 --- a/config/runner.yml +++ b/config/runner.yml @@ -40,12 +40,10 @@ drupal: # Setting this to "false" will run "site-install" without the "--db-url" parameter. # This is useful if the database settings are already set in your settings.php file. generate_db_url: true - # By setting this to FALSE, will disable the update status module option - # (install_configure_form.enable_update_status_module) during "site-install" execution. By default, is TRUE. - update_status_module: "true" - # By setting this to FALSE, will disable the update status emails option - # (install_configure_form.enable_update_status_emails) during "site-install" execution. By default, is TRUE. - update_status_emails: "true" + # Setting this to "false" will tell the "site-install" command to not enable the update status module. + update_status_module: true + # Setting this to "false" will tell the "site-install" command to disable email notifications about updates. + update_status_emails: true # Administrator account information. account: diff --git a/src/Commands/AbstractDrupalCommands.php b/src/Commands/AbstractDrupalCommands.php index 3167ce6..7895361 100644 --- a/src/Commands/AbstractDrupalCommands.php +++ b/src/Commands/AbstractDrupalCommands.php @@ -178,9 +178,9 @@ public function siteInstall(array $options = [ $options['existing-config'] = true; } - // Adapt values for the installation configuration form parameters. - $options['enable-update-status-module'] = filter_var($options['enable-update-status-module'], FILTER_VALIDATE_BOOLEAN) === false ? 'NULL' : $options['enable-update-status-module']; - $options['enable-update-status-emails'] = filter_var($options['enable-update-status-emails'], FILTER_VALIDATE_BOOLEAN) === false ? 'NULL' : $options['enable-update-status-emails']; + // Pass value as boolean type only. + $options['enable-update-status-module'] = filter_var($options['enable-update-status-module'], FILTER_VALIDATE_BOOLEAN); + $options['enable-update-status-emails'] = filter_var($options['enable-update-status-emails'], FILTER_VALIDATE_BOOLEAN); $drush = $this->getConfig()->get('runner.bin_dir') . '/drush'; $task = $this->taskDrush($drush) @@ -199,8 +199,8 @@ public function siteInstall(array $options = [ ->databaseName($options['database-name']) ->sitesSubdir($options['sites-subdir']) ->siteProfile($options['site-profile']) - ->setUpdateStatusModule($options['enable-update-status-module']) - ->setUpdateStatusEmails($options['enable-update-status-emails']); + ->setEnableStatusModuleOnInstall($options['enable-update-status-module']) + ->setEnableUpdateStatusEmailsOnInstall($options['enable-update-status-emails']); $task->setGenerateDbUrl($this->getConfig()->get('drupal.site.generate_db_url')); diff --git a/src/Tasks/Drush/Drush.php b/src/Tasks/Drush/Drush.php index d42cb42..c7bd613 100644 --- a/src/Tasks/Drush/Drush.php +++ b/src/Tasks/Drush/Drush.php @@ -73,8 +73,9 @@ public function siteInstall() return $this->arg('site-install') ->arg($this->siteProfile) - ->rawArg("install_configure_form.enable_update_status_module=" . $this->updateStatusModule) - ->rawArg("install_configure_form.enable_update_status_emails=" . $this->updateStatusEmails); + // Adapt values for the installation configuration form parameters. + ->rawArg('install_configure_form.enable_update_status_module=' . ($this->updateStatusModule ? 'true' : 'NULL')) + ->rawArg('install_configure_form.enable_update_status_emails=' . ($this->updateStatusEmails ? 'true' : 'NULL')); } /** @@ -294,25 +295,25 @@ public function setGenerateDbUrl($generateDbUrl) } /** - * @param bool $updateStatusModule + * @param bool $enable * * @return Drush */ - public function setUpdateStatusModule($updateStatusModule) + public function setEnableStatusModuleOnInstall($enable) { - $this->updateStatusModule = $updateStatusModule; + $this->updateStatusModule = $enable; return $this; } /** - * @param bool $updateStatusEmails + * @param bool $enable * * @return Drush */ - public function setUpdateStatusEmails($updateStatusEmails) + public function setEnableUpdateStatusEmailsOnInstall($enable) { - $this->updateStatusEmails = $updateStatusEmails; + $this->updateStatusEmails = $enable; return $this; }