X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fwebflo%2Fdrupal-finder%2Fsrc%2FDrupalFinder.php;fp=vendor%2Fwebflo%2Fdrupal-finder%2Fsrc%2FDrupalFinder.php;h=642ea8f78ca9c0bef612e7e01f09390742d4b1db;hp=083504076087630a2f64a5e4cc269bf0993aa312;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/webflo/drupal-finder/src/DrupalFinder.php b/vendor/webflo/drupal-finder/src/DrupalFinder.php index 083504076..642ea8f78 100644 --- a/vendor/webflo/drupal-finder/src/DrupalFinder.php +++ b/vendor/webflo/drupal-finder/src/DrupalFinder.php @@ -85,7 +85,7 @@ class DrupalFinder */ protected function isValidRoot($path) { - if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php') && file_exists($path . '/composer.json')) { + if (!empty($path) && is_dir($path) && file_exists($path . '/autoload.php') && file_exists($path . '/' . $this->getComposerFileName())) { // 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'; @@ -97,30 +97,34 @@ class DrupalFinder } } } - if (!empty($path) && is_dir($path) && file_exists($path . '/composer.json')) { + if (!empty($path) && is_dir($path) && file_exists($path . '/' . $this->getComposerFileName())) { $json = json_decode( - file_get_contents($path . '/composer.json'), + file_get_contents($path . '/' . $this->getComposerFileName()), true ); if (is_array($json)) { if (isset($json['extra']['installer-paths']) && is_array($json['extra']['installer-paths'])) { foreach ($json['extra']['installer-paths'] as $install_path => $items) { - if (in_array('type:drupal-core', $items) || in_array('drupal/core', $items)) { + if (in_array('type:drupal-core', $items) || + in_array('drupal/core', $items) || + in_array('drupal/drupal', $items)) { $this->composerRoot = $path; - $this->drupalRoot = $path . '/' . substr( - $install_path, - 0, - -5 - ); + // @todo: Remove this magic and detect the major version instead. + if ($install_path == 'core') { + $install_path = null; + } elseif (substr($install_path, -5) == '/core') { + $install_path = substr($install_path, 0, -5); + } + $this->drupalRoot = rtrim($path . '/' . $install_path, '/'); $this->vendorDir = $this->composerRoot . '/vendor'; } } } } } - if ($this->composerRoot && file_exists($this->composerRoot . '/composer.json')) { + if ($this->composerRoot && file_exists($this->composerRoot . '/' . $this->getComposerFileName())) { $json = json_decode( - file_get_contents($path . '/composer.json'), + file_get_contents($path . '/' . $this->getComposerFileName()), true ); if (is_array($json) && isset($json['config']['vendor-dir'])) { @@ -147,6 +151,14 @@ class DrupalFinder return $this->composerRoot; } + /** + * @return string + */ + protected function getComposerFileName() + { + return trim(getenv('COMPOSER')) ?: 'composer.json'; + } + /** * @return string */