function DrupalBoot8::valid_root

8.0.x DrupalBoot8.php DrupalBoot8::valid_root($path)
7.x DrupalBoot8.php DrupalBoot8::valid_root($path)
master DrupalBoot8.php DrupalBoot8::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/DrupalBoot8.php, line 27

Namespace

Drush\Boot

Class

DrupalBoot8

Code

function valid_root($path) {
  if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php')) {
    // Additional check for the presence of core/composer.json to
    // grant it is not a Drupal 7 site with a base folder named "core".
    $candidate = 'core/includes/common.inc';
    if (file_exists($path . '/' . $candidate) && file_exists($path . '/core/core.services.yml')) {
      if (file_exists($path . '/core/misc/drupal.js') || file_exists($path . '/core/assets/js/drupal.js')) {
        return $candidate;
      }
    }
  }
}