c7f3cdfa619ccc49b7beca63ba472fd1ee606f15
[yaffs-website] / vendor / drush / drush / commands / core / drupal / site_install_7.inc
1 <?php
2
3 use Drush\Log\LogLevel;
4
5 /**
6  * Install Drupal 7
7  */
8 function drush_core_site_install_version($profile, array $additional_form_options = array()) {
9   require_once DRUSH_DRUPAL_CORE . '/includes/install.core.inc';
10
11   if (!isset($profile)) {
12     require_once DRUSH_DRUPAL_CORE . '/includes/file.inc';
13     require_once DRUSH_DRUPAL_CORE . '/includes/install.inc';
14     require_once DRUSH_DRUPAL_CORE . '/includes/common.inc';
15     require_once DRUSH_DRUPAL_CORE . '/includes/module.inc';
16
17     // If there is an installation profile that is marked as exclusive, use that
18     // one.
19     try {
20       $profile = _install_select_profile(install_find_profiles());
21     }
22     catch (\Exception $e) {
23       // This is only a best effort to provide a better default, no harm done
24       // if it fails.
25     }
26     if (empty($profile)) {
27       $profile = 'standard';
28     }
29   }
30
31   $sql = drush_sql_get_class();
32   $db_spec = $sql->db_spec();
33
34   $account_name = drush_get_option('account-name', 'admin');
35   $account_pass = drush_get_option('account-pass', FALSE);
36   $show_password = drush_get_option('show-passwords', !$account_pass);
37   if (!$account_pass) {
38     $account_pass = drush_generate_password();
39   }
40   $settings = array(
41     'parameters' => array(
42       'profile' => $profile,
43       'locale' => drush_get_option('locale', 'en'),
44     ),
45     'forms' => array(
46       'install_settings_form' => array(
47         'driver' => $db_spec['driver'],
48         $db_spec['driver'] => $db_spec,
49         'op' => dt('Save and continue'),
50       ),
51       'install_configure_form' => array(
52         'site_name' => drush_get_option('site-name', 'Site-Install'),
53         'site_mail' => drush_get_option('site-mail', 'admin@example.com'),
54         'account' => array(
55           'name' => $account_name,
56           'mail' => drush_get_option('account-mail', 'admin@example.com'),
57           'pass' => array(
58             'pass1' => $account_pass,
59             'pass2' => $account_pass,
60           ),
61         ),
62         'update_status_module' => array(
63           1 => TRUE,
64           2 => TRUE,
65         ),
66         'clean_url' => drush_get_option('clean-url', TRUE),
67         'op' => dt('Save and continue'),
68       ),
69     ),
70   );
71
72   // Merge in the additional options.
73   foreach ($additional_form_options as $key => $value) {
74     $current = &$settings['forms'];
75     foreach (explode('.', $key) as $param) {
76       $current = &$current[$param];
77     }
78     $current = $value;
79   }
80
81   $msg = 'Starting Drupal installation. This takes a while.';
82   if (is_null(drush_get_option('notify'))) {
83     $msg .= ' Consider using the --notify global option.';
84   }
85   drush_log(dt($msg), LogLevel::OK);
86   drush_op('install_drupal', $settings);
87   if ($show_password) {
88     drush_log(dt('Installation complete.  User name: @name  User password: @pass', array('@name' => $account_name, '@pass' => $account_pass)), LogLevel::OK);
89   }
90   else {
91     drush_log(dt('Installation complete.'), LogLevel::OK);
92   }
93 }