You are here

function get_drupal_root_directory in Gutenberg 8.2

Gets the Drupal root directory.

Return value

string The root directory.

1 call to get_drupal_root_directory()
gutenberg-dependencies.php in scripts/gutenberg-dependencies.php
Gets Gutenberg dependencies.

File

scripts/gutenberg-dependencies.php, line 25
Gets Gutenberg dependencies.

Code

function get_drupal_root_directory() {
  $dirs = explode(DIRECTORY_SEPARATOR, __DIR__);
  $root_dir = [];
  foreach ($dirs as $key => $value) {
    if ($value === 'modules') {
      return implode(DIRECTORY_SEPARATOR, $root_dir);
    }
    $root_dir[] = $value;
  }
  throw new \RuntimeException('Could not find the Drupal root.');
}