You are here

public function DatabaseSanitize::getSourceLocations in Database Sanitize 8

Gets the source directories to scan for sanitize YML files.

Return value

array An array containing the locations.

1 call to DatabaseSanitize::getSourceLocations()
DatabaseSanitize::__construct in src/DatabaseSanitize.php
DatabaseSanitize constructor.

File

src/DatabaseSanitize.php, line 84

Class

DatabaseSanitize
Class DatabaseSanitize.

Namespace

Drupal\database_sanitize

Code

public function getSourceLocations() {
  $merge_yaml_config = $this
    ->getMergeYamlConfig();
  $default_locations = [
    DRUPAL_ROOT . '/modules',
    DRUPAL_ROOT . '/profiles',
  ];
  $locations = $default_locations;
  if (!empty($merge_yaml_config['locations'])) {
    $locations = $merge_yaml_config['locations'];
  }

  // @TODO we are assuming here the location of composer.json.
  $composer_file = DRUPAL_ROOT . '/../composer.json';
  $composer_root = dirname($composer_file);

  // Converts paths to be absolute.
  foreach ($locations as &$location) {
    if (!file_exists($location)) {
      $location = realpath("{$composer_root}/{$location}");
    }
  }
  unset($location);
  return $locations;
}