function DrupalBoot6::valid_root

8.0.x DrupalBoot6.php DrupalBoot6::valid_root($path)
7.x DrupalBoot6.php DrupalBoot6::valid_root($path)
master DrupalBoot6.php DrupalBoot6::valid_root($path)

This function determines if the specified path points to the root directory of a CMS that can be bootstrapped by the specific subclass that implements it.

These functions should be written such that one and only one class will return TRUE for any given $path.

Parameters

$path to a directory to test:

Return value

TRUE if $path is a valid root directory

Overrides DrupalBoot::valid_root

File

lib/Drush/Boot/DrupalBoot6.php, line 14
This file is required for recognizing a D6 root and showing deprecation error.

Namespace

Drush\Boot

Class

DrupalBoot6

Code

function valid_root($path) {
  if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
    // Drupal 6 root.
    // We check for the absence of 'modules/field/field.module' to differentiate this from a D7 site.
    // n.b. we want D5 and earlier to match here, if possible, so that we can print a 'not supported'
    // error durring bootstrap.  If someone later adds a commandfile that adds a boot class for
    // Drupal 5, it will be tested first, so we shouldn't get here.
    $candidate = 'includes/common.inc';
    if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && !file_exists($path . '/modules/field/field.module')) {
      return $candidate;
    }
  }
}