Skip to content

Commit

Permalink
ACMS-3658: Minor code refactored.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkhode1 committed Mar 19, 2024
1 parent 58ae947 commit 9f4f6a5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acquia\Drupal\RecommendedSettings;

use Acquia\Drupal\RecommendedSettings\Drush\Commands\SettingsDrushCommands;
use Acquia\Drupal\RecommendedSettings\Exceptions\SettingsException;
use Composer\Composer;
use Composer\DependencyResolver\Operation\InstallOperation;
Expand Down Expand Up @@ -94,16 +95,17 @@ public function onPostPackageEvent(PackageEvent $event): void {

/**
* Includes Acquia recommended settings post composer update/install command.
*
* @throws \Acquia\Drupal\RecommendedSettings\Exceptions\SettingsException
*/
public function onPostCmdEvent(): void {
// Only install the template files, if the drupal-recommended-settings
// plugin is installed, with drupal project.
if ($this->settingsPackage && $this->getDrupalRoot()) {
try {
$vendor_dir = $this->composer->getConfig()->get('vendor-dir');
$this->executeCommand($vendor_dir . "/bin/drush drs:init:settings", [], TRUE);
$this->executeCommand(
$vendor_dir . "/bin/drush " . SettingsDrushCommands::SETTINGS_COMMAND, [],
TRUE
);
}
catch (SettingsException $e) {
$this->io->write("<fg=white;bg=red;options=bold>[error]</> " . $e->getMessage());
Expand Down Expand Up @@ -178,13 +180,12 @@ protected function executeCommand(string $cmd, array $args = [], bool $display_o
array_unshift($args, $cmd);
// And replace the arguments.
$command = call_user_func_array('sprintf', $args);
$output = '';
if ($this->io->isVerbose() || $display_output) {
$this->io->write('<comment> > ' . $command . '</comment>');
$io = $this->io;
$output = function ($type, $buffer) use ($io): void {
function ($type, $buffer) use ($io): void {
$io->write($buffer, FALSE);
};
}
}
return ($this->executor->executeTty($command) == 0);
}
Expand Down

0 comments on commit 9f4f6a5

Please sign in to comment.