*/
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;
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';
}
}
}
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;
}
/**
{
return $this->composerRoot;
}
+
+ /**
+ * @return string
+ */
+ public function getVendorDir()
+ {
+ return $this->vendorDir;
+ }
}