DrupalBoot7.php

  1. 8.0.x lib/Drush/Boot/DrupalBoot7.php
  2. 7.x lib/Drush/Boot/DrupalBoot7.php
  3. master lib/Drush/Boot/DrupalBoot7.php

Namespace

Drush\Boot

Classes

Namesort descending Description
DrupalBoot7

File

lib/Drush/Boot/DrupalBoot7.php
View source
  1. <?php
  2. namespace Drush\Boot;
  3. use Psr\Log\LoggerInterface;
  4. class DrupalBoot7 extends DrupalBoot {
  5. function valid_root($path) {
  6. if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
  7. // Drupal 7 root.
  8. // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
  9. $candidate = 'includes/common.inc';
  10. if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
  11. return $candidate;
  12. }
  13. }
  14. }
  15. function get_version($drupal_root) {
  16. $path = $drupal_root . '/includes/bootstrap.inc';
  17. if (is_file($path)) {
  18. require_once $path;
  19. if (defined('VERSION')) {
  20. return VERSION;
  21. }
  22. }
  23. }
  24. function get_profile() {
  25. return drupal_get_profile();
  26. }
  27. function add_logger() {
  28. // If needed, prod module_implements() to recognize our system_watchdog() implementation.
  29. $dogs = drush_module_implements('watchdog');
  30. if (!in_array('system', $dogs)) {
  31. // Note that we must never clear the module_implements() cache because
  32. // that would trigger larger cache rebuilds with system_cache_tables on
  33. // every drush invocation. Instead we inject our system_watchdog()
  34. // implementation direclty into the static cache.
  35. $implementations = &drupal_static('module_implements');
  36. $implementations['watchdog']['system'] = FALSE;
  37. $verified_implementations = &drupal_static('module_implements:verified');
  38. $verified_implementations['watchdog'] = TRUE;
  39. }
  40. }
  41. function contrib_modules_paths() {
  42. return array(
  43. $this->conf_path() . '/modules',
  44. 'sites/all/modules',
  45. );
  46. }
  47. function contrib_themes_paths() {
  48. return array(
  49. $this->conf_path() . '/themes',
  50. 'sites/all/themes',
  51. );
  52. }
  53. function bootstrap_drupal_core($drupal_root) {
  54. define('DRUPAL_ROOT', $drupal_root);
  55. require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
  56. $core = DRUPAL_ROOT;
  57. return $core;
  58. }
  59. function bootstrap_drupal_database_validate() {
  60. return parent::bootstrap_drupal_database_validate() && $this->bootstrap_drupal_database_has_table('blocked_ips');
  61. }
  62. function bootstrap_drupal_database() {
  63. drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
  64. parent::bootstrap_drupal_database();
  65. }
  66. function bootstrap_drupal_configuration() {
  67. drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
  68. // Unset drupal error handler and restore drush's one.
  69. restore_error_handler();
  70. parent::bootstrap_drupal_configuration();
  71. }
  72. function bootstrap_drupal_full() {
  73. if (!drush_get_context('DRUSH_QUIET', FALSE)) {
  74. ob_start();
  75. }
  76. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  77. if (!drush_get_context('DRUSH_QUIET', FALSE)) {
  78. ob_end_clean();
  79. }
  80. parent::bootstrap_drupal_full();
  81. }
  82. }