site_install.inc

  1. 8.0.x commands/core/drupal/site_install.inc
  2. 6.x commands/core/drupal/site_install.inc
  3. 7.x commands/core/drupal/site_install.inc
  4. 4.x commands/core/drupal/site_install.inc
  5. 5.x commands/core/drupal/site_install.inc
  6. master commands/core/drupal/site_install.inc

Functions

Namesort descending Description
drush_core_site_install_version Install Drupal 8+

File

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