site_install_7.inc

  1. 8.0.x commands/core/drupal/site_install_7.inc
  2. 7.x commands/core/drupal/site_install_7.inc
  3. master commands/core/drupal/site_install_7.inc

Functions

Namesort descending Description
drush_core_site_install_version Install Drupal 7

File

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