More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / drush / drush / includes / drupal.inc
1 <?php
2
3 /**
4  * @file
5  * Utility functions related to Drupal.
6  */
7
8 use Drush\Drush;
9
10 /**
11  * Detects the version number of the current Drupal installation,
12  * if any. Returns FALSE if there is no current Drupal installation,
13  * or it is somehow broken.
14  *
15  * @return
16  *   A string containing the version number of the current
17  *   Drupal installation, if any. Otherwise, return FALSE.
18  */
19 function drush_drupal_version($drupal_root = NULL) {
20   static $version = FALSE;
21
22   if (!$version) {
23     if (($drupal_root != NULL) || ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'))) {
24       $bootstrap = Drush::bootstrapManager()->bootstrapObjectForRoot($drupal_root);
25       if ($bootstrap) {
26         $version = $bootstrap->getVersion($drupal_root);
27       }
28     }
29   }
30   return $version;
31 }
32
33 function drush_drupal_cache_clear_all() {
34   drush_invoke_process('@self', 'cache-rebuild');
35 }
36
37 /**
38  * Returns the Drupal major version number (6, 7, 8 ...)
39  */
40 function drush_drupal_major_version($drupal_root = NULL) {
41   $major_version = FALSE;
42   if ($version = drush_drupal_version($drupal_root)) {
43     $version_parts = explode('.', $version);
44     if (is_numeric($version_parts[0])) {
45       $major_version = (integer)$version_parts[0];
46     }
47   }
48   return $major_version;
49 }