public function getToolstack()
{
$toolstackChoice = false;
// For now, we reconstruct a toolstack string based on the 'type' and
// 'build.flavor' config keys.
$appConfig = $this->getConfig();
if (isset($appConfig['type'])) {
list($stack, ) = explode(':', $appConfig['type'], 2);
$flavor = isset($appConfig['build']['flavor']) ? $appConfig['build']['flavor'] : 'default';
// Toolstack classes for HHVM are the same as PHP.
if ($stack === 'hhvm') {
$stack = 'php';
}
$toolstackChoice = "{$stack}:{$flavor}";
// Alias php:default to php:composer.
if ($toolstackChoice === 'php:default') {
$toolstackChoice = 'php:composer';
}
if ($flavor === 'none') {
$toolstackChoice = 'none';
}
}
foreach (self::getToolstacks() as $toolstack) {
$key = $toolstack->getKey();
if (!$toolstackChoice && $toolstack->detect($this->getRoot()) || $key && $toolstackChoice === $key) {
return $toolstack;
}
}
if ($toolstackChoice) {
throw new \Exception("Toolstack not found: {$toolstackChoice}");
}
return false;
}