diff --git a/src/Config/ConfigInitializer.php b/src/Config/ConfigInitializer.php index 84fbaf8..1a9bc72 100644 --- a/src/Config/ConfigInitializer.php +++ b/src/Config/ConfigInitializer.php @@ -28,7 +28,7 @@ class ConfigInitializer { /** * Processor. * - * @var Acquia\Drupal\RecommendedSettings\Config\YamlConfigProcessor + * @var \Acquia\Drupal\RecommendedSettings\Config\YamlConfigProcessor */ protected $processor; diff --git a/src/Config/SettingsConfig.php b/src/Config/SettingsConfig.php index 2ac1e91..97c0629 100644 --- a/src/Config/SettingsConfig.php +++ b/src/Config/SettingsConfig.php @@ -11,6 +11,13 @@ */ class SettingsConfig extends Config { + /** + * Holds the YamlExpander class object. + * + * @var \Grasmash\YamlExpander\YamlExpander + */ + protected $expander; + /** * Config Constructor. * @@ -29,7 +36,7 @@ public function __construct(array $data = []) { * @param string $filename * The file in which placeholders should be expanded. */ - public function expandFileProperties($filename) { + public function expandFileProperties(string $filename) { $expanded_contents = $this->expander->expandArrayProperties(file($filename), $this->export()); file_put_contents($filename, implode("", $expanded_contents)); } diff --git a/src/Plugin.php b/src/Plugin.php index 0da1dea..2617e64 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -36,18 +36,11 @@ class Plugin implements PluginInterface, EventSubscriberInterface { protected $io; /** - * The Composer Scaffold handler. + * Stores this plugin package object. * - * @var \Drupal\Composer\Plugin\Scaffold\Handler + * @var mixed|null */ - protected $handler; - - /** - * Record whether the 'require' command was called. - * - * @var bool - */ - protected $drsIncluded; + protected $settingsPackage; /** * {@inheritdoc} @@ -55,7 +48,6 @@ class Plugin implements PluginInterface, EventSubscriberInterface { public function activate(Composer $composer, IOInterface $io) { $this->composer = $composer; $this->io = $io; - $this->drsIncluded = FALSE; } /** @@ -83,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. @@ -98,13 +90,14 @@ 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. - if (isset($this->settingsPackage)) { + // 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(); $settings->generateSettings(); @@ -133,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; - } - } - } - } - }