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