Skip to content

Commit

Permalink
Merge pull request #10 from acquia/ACMS-1866
Browse files Browse the repository at this point in the history
ACMS-1866: Fixed the PHP 8.2 deprecation notices.
  • Loading branch information
vishalkhode1 authored Jun 26, 2023
2 parents 50b547e + c9291ab commit e316649
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 38 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
9 changes: 8 additions & 1 deletion src/Config/SettingsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
*/
class SettingsConfig extends Config {

/**
* Holds the YamlExpander class object.
*
* @var \Grasmash\YamlExpander\YamlExpander
*/
protected $expander;

/**
* Config Constructor.
*
Expand All @@ -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));
}
Expand Down
44 changes: 8 additions & 36 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,18 @@ 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}
*/
public function activate(Composer $composer, IOInterface $io) {
$this->composer = $composer;
$this->io = $io;
$this->drsIncluded = FALSE;
}

/**
Expand Down Expand Up @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
}
}
}

}

0 comments on commit e316649

Please sign in to comment.