private function getTerminusRoot($current_dir = null)
{
if (isset($this->config['root'])) {
return $this->config['root'];
}
if (defined('TERMINUS_ROOT')) {
return TERMINUS_ROOT;
}
if (is_null($current_dir)) {
$current_dir = dirname(__DIR__);
}
if (file_exists("{$current_dir}/composer.json")) {
return $current_dir;
}
$dir = explode('/', $current_dir);
array_pop($dir);
if (empty($dir)) {
throw new TerminusException('Could not locate root to set TERMINUS_ROOT.');
}
$dir = implode('/', $dir);
$root_dir = $this->getTerminusRoot($dir);
return $root_dir;
}