Skip to content

Commit

Permalink
ACMS-1866: Code cleanup & fixed PHPCS issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkhode1 committed Jun 26, 2023
1 parent 2fcb11e commit c9291ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Config/ConfigInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ConfigInitializer {
/**
* Processor.
*
* @var Acquia\Drupal\RecommendedSettings\Config\YamlConfigProcessor
* @var \Acquia\Drupal\RecommendedSettings\Config\YamlConfigProcessor
*/
protected $processor;

Expand Down
43 changes: 4 additions & 39 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
*/
protected $io;

/**
* The Composer Scaffold handler.
*
* @var \Drupal\Composer\Plugin\Scaffold\Handler
*/
protected $handler;

/**
* Record whether the 'require' command was called.
*
* @var bool
*/
protected $drsIncluded;

/**
* Stores this plugin package object.
*
Expand All @@ -62,7 +48,6 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
public function activate(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
$this->drsIncluded = FALSE;
}

/**
Expand Down Expand Up @@ -90,7 +75,7 @@ public static function getSubscribedEvents() {
}

/**
* Marks Acquia Drupal Recommended Settings to be processed after an install or update command.
* Marks this plugin to be processed after package install or update event.
*
* @param \Composer\Installer\PackageEvent $event
* Event.
Expand All @@ -105,12 +90,13 @@ public function onPostPackageEvent(PackageEvent $event) {
}

/**
* Execute Acquia Drupal Recommended Settings drs:update after update command has been executed.
* Includes Acquia recommended settings post composer update/install command.
*
* @throws \Exception
*/
public function onPostCmdEvent() {
// Only install the template files if acquia/drupal-recommended-settings was installed.
// Only install the template files, if the drupal-recommended-settings
// plugin is installed.
if ($this->settingsPackage) {
$settings = new Settings($this->composer, $this->io, $this->settingsPackage);
$settings->hashSalt();
Expand Down Expand Up @@ -140,25 +126,4 @@ protected function getSettingsPackage(OperationInterface $operation) {
return NULL;
}

/**
* Hook for pre-package install.
*/
public function prePackageInstall(PackageEvent $event) {
if (!$this->drsIncluded) {
$operations = $event->getOperations();
foreach ($operations as $operation) {
if ($operation instanceof InstallOperation) {
$package = $operation->getPackage();
}
elseif ($operation instanceof UpdateOperation) {
$package = $operation->getTargetPackage();
}
if (isset($package) && $package instanceof PackageInterface && $package->getName() == 'acquia/drupal-recommended-settings') {
$this->drsIncluded = TRUE;
break;
}
}
}
}

}

0 comments on commit c9291ab

Please sign in to comment.