X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fwebflo%2Fdrupal-finder%2Fsrc%2FDrupalFinder.php;h=083504076087630a2f64a5e4cc269bf0993aa312;hb=93ef30d42f68e55d11d97312531118bbcd4cf318;hp=efa43892a0b1567b8f1ffb00b23c66817469ce16;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/webflo/drupal-finder/src/DrupalFinder.php b/vendor/webflo/drupal-finder/src/DrupalFinder.php index efa43892a..083504076 100644 --- a/vendor/webflo/drupal-finder/src/DrupalFinder.php +++ b/vendor/webflo/drupal-finder/src/DrupalFinder.php @@ -23,10 +23,20 @@ class DrupalFinder */ private $composerRoot; + /** + * Composer vendor directory. + * + * @var string + * + * @see https://getcomposer.org/doc/06-config.md#vendor-dir + */ + private $vendorDir; + public function locateRoot($start_path) { $this->drupalRoot = false; $this->composerRoot = false; + $this->vendorDir = false; foreach (array(true, false) as $follow_symlinks) { $path = $start_path; @@ -83,6 +93,7 @@ class DrupalFinder if (file_exists($path . '/core/misc/drupal.js') || file_exists($path . '/core/assets/js/drupal.js')) { $this->composerRoot = $path; $this->drupalRoot = $path; + $this->vendorDir = $this->composerRoot . '/vendor'; } } } @@ -101,13 +112,23 @@ class DrupalFinder 0, -5 ); + $this->vendorDir = $this->composerRoot . '/vendor'; } } } } } + if ($this->composerRoot && file_exists($this->composerRoot . '/composer.json')) { + $json = json_decode( + file_get_contents($path . '/composer.json'), + true + ); + if (is_array($json) && isset($json['config']['vendor-dir'])) { + $this->vendorDir = $this->composerRoot . '/' . $json['config']['vendor-dir']; + } + } - return $this->drupalRoot && $this->composerRoot; + return $this->drupalRoot && $this->composerRoot && $this->vendorDir; } /** @@ -125,4 +146,12 @@ class DrupalFinder { return $this->composerRoot; } + + /** + * @return string + */ + public function getVendorDir() + { + return $this->vendorDir; + } }