-
Notifications
You must be signed in to change notification settings - Fork 0
/
db-sanitization-modules.php
25 lines (23 loc) · 1.32 KB
/
db-sanitization-modules.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/**
* Enables the devel, and reroute_email modules when a database is cloned to a dev environment.
*/
// The clone_database may be triggered on any environment, but we only want
// to automatically enable the devel module when this event happens a dev
// or multidev environment.
if (isset($_POST['environment']) && !in_array($_POST['environment'], array('live'))) {
// First, let's retrieve a list of disabled modules with drush pm-list.
// shell_exec() will return the output of an executable as a string.
// Pass the --format=json flag into the drush command so the output can be converted into an array with json_decode().
$modules = json_decode(shell_exec('drush pm-list --format=json'));
// Now let's enable devel if it is installed and not already enabled.
if (isset($modules->devel) && $modules->devel->status !== 'Enabled') {
// This time let's just passthru() to run the drush command so the command output prints to the workflow log.
passthru('drush pm-enable -y devel');
}
// Noe let's enable reroute_email if it is installed and not already enabled.
if (isset($modules->reroute_email) && $modules->reroute_email->status !== 'Enabled') {
// This time let's just passthru() to run the drush command so the command output prints to the workflow log.
passthru('drush pm-enable -y reroute_email');
}
}