From 74f3c36e18bdcba72d89b2ee4e953b11a88fd9d0 Mon Sep 17 00:00:00 2001 From: Ankit Pathak <106175376+apathak18@users.noreply.github.com> Date: Wed, 10 Jan 2024 23:41:57 +0530 Subject: [PATCH 1/2] ACMS-3478: Update README.md file. --- README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 278cc06..72e23e6 100644 --- a/README.md +++ b/README.md @@ -12,23 +12,17 @@ It allows your websites to be easily installed in both Acquia Cloud IDE & local and deployable on Acquia Cloud. ## Installation +### Install using Composer -### Include Acquia Global Command in DRS for multisite functionality -To use global command with DRS for multisite functionality please add below in -your root composer.json file. ``` -"repositories": { - "acquia_global_commands": { - "type": "vcs", - "url": "git@github.com:vishalkhode1/acquia_global_commands.git" - } -} +composer require acquia/drupal-recommended-settings ``` +### Multi-site features with Acquia DRS +Acquia Global Commands comes in role to setup multi-site with Drupal Recommended Settings. -You can also install this using Composer like so: - +To setup a multi-site, please run below command. ``` -composer require acquia/drupal-recommended-settings +drush site:install --uri site1 ``` # Quick examples @@ -77,7 +71,7 @@ $settings = new Settings(DRUPAL_ROOT, $siteUri); $dbSpec = [ 'drupal' => [ 'db' => [ - 'database' => 'drupal', + 'database' => 'drupal', // In case of multi-site database name is replaced with the site name. 'username' => 'drupal', 'password' => 'drupal', 'host' => 'localhost', From 01b51ac21395c5b8f874cb19cc53096389db25fa Mon Sep 17 00:00:00 2001 From: Vishal Khode Date: Wed, 17 Jan 2024 18:10:18 +0530 Subject: [PATCH 2/2] ACMS-3478: Updated README.md file. --- README.md | 18 ++++++--- examples/example-drush-command/README.md | 2 + examples/example-drush-command/composer.json | 22 +++++++++++ .../Drush/Commands/ExampleDrushCommands.php | 37 +++++++++++++++++++ 4 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 examples/example-drush-command/README.md create mode 100644 examples/example-drush-command/composer.json create mode 100644 examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php diff --git a/README.md b/README.md index 72e23e6..8ebbfdd 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,23 @@ It allows your websites to be easily installed in both Acquia Cloud IDE & local and deployable on Acquia Cloud. ## Installation -### Install using Composer +### Install using Composer ``` composer require acquia/drupal-recommended-settings ``` ### Multi-site features with Acquia DRS -Acquia Global Commands comes in role to setup multi-site with Drupal Recommended Settings. - -To setup a multi-site, please run below command. +The Drupal Recommended Settings offer the multi-site feature out of the box. +To configure a multi-site, run the following command, and the plugin will +automatically generate the settings.php in the backend. ``` drush site:install --uri site1 ``` +The plugin offers various events that allow you to implement custom logic based +on when these events are triggered. You can find the examples of such +implementations from [here](examples). + # Quick examples ## Generate settings for a given site ``` @@ -45,7 +49,8 @@ $settings = new Settings(DRUPAL_ROOT, $siteUri); try { // Call generate method. $settings->generate(); -} catch (SettingsException $e) { +} +catch (SettingsException $e) { echo $e->getMessage(); } ``` @@ -83,7 +88,8 @@ $dbSpec = [ try { // Call generate method passing database details. $settings->generate($dbSpec); -} catch (SettingsException $e) { +} +catch (SettingsException $e) { echo $e->getMessage(); } ``` diff --git a/examples/example-drush-command/README.md b/examples/example-drush-command/README.md new file mode 100644 index 0000000..14e8dde --- /dev/null +++ b/examples/example-drush-command/README.md @@ -0,0 +1,2 @@ +## About +Provides an example implemention of events provided by DRS. diff --git a/examples/example-drush-command/composer.json b/examples/example-drush-command/composer.json new file mode 100644 index 0000000..7c34f63 --- /dev/null +++ b/examples/example-drush-command/composer.json @@ -0,0 +1,22 @@ +{ + "name": "example/example-drush-command", + "description": "Example custom drush commands.", + "keywords": [ + "drush", + "drupal" + ], + "license": "GPL-2.0-or-later", + "require": { + "acquia/drupal-recommended-settings": "*" + }, + "autoload": { + "psr-4": { + "Example\\": "src" + } + }, + "config": { + "allow-plugins": { + "acquia/drupal-recommended-settings": true + } + } +} \ No newline at end of file diff --git a/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php b/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php new file mode 100644 index 0000000..3e72bf9 --- /dev/null +++ b/examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php @@ -0,0 +1,37 @@ +input()->getOption("uri") == "site1") { + return FALSE; + } + return TRUE; + } + + /** + * Display successful message, after settings files are generated/updated. + */ + #[CLI\Hook(type: HookManager::ON_EVENT, target: MultisiteDrushCommands::POST_GENERATE_SETTINGS)] + public function showSuccessMessage(CommandData $commandData): void { + $uri = $commandData->input()->getOption("uri"); + $this->io()->info("The settings.php generated successfully for site `" . $uri . "`."); + } + +}