forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrupalCommand.php
59 lines (49 loc) · 1.75 KB
/
DrupalCommand.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Acquia\Blt\Robo\Commands\Drupal;
use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Common\RandomString;
/**
* Defines commands in the "drupal:*" namespace.
*/
class DrupalCommand extends BltTasks {
/**
* Installs Drupal.
*
* @command drupal:install
*
* @validateMySqlAvailable
*
* @return \Robo\Result
* The `drush site-install` command result.
*/
public function install() {
// Generate a random, valid username.
// @see \Drupal\user\Plugin\Validation\Constraint\UserNameConstraintValidator
$username = RandomString::string(10, FALSE,
function ($string) {
return !preg_match('/[^\x{80}-\x{F7} a-z0-9@+_.\'-]/i', $string);
},
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#%^&*()_-?/.,+=><'
);
$task = $this->taskDrush()
->drush("site-install")
->arg($this->getConfigValue('project.profile.name'))
->rawArg("install_configure_form.update_status_module='array(FALSE,FALSE)'")
->option('site-name', $this->getConfigValue('project.human_name'))
->option('site-mail', $this->getConfigValue('drupal.account.mail'))
->option('account-name', $username, '=')
->option('account-mail', $this->getConfigValue('drupal.account.mail'))
->option('locale', $this->getConfigValue('drupal.locale'))
->assume(TRUE)
->printOutput(TRUE);
if (!$this->getConfigValue('cm.strategy') == 'features') {
$cm_core_key = $this->getConfigValue('cm.core.key');
$task->option('config-dir', $this->getConfigValue("cm.core.dirs.$cm_core_key.path"));
}
$result = $task->interactive()->run();
if ($result->wasSuccessful()) {
$this->getConfig()->set('state.drupal.installed', TRUE);
}
return $result;
}
}