'index',
'$TaskName' => 'runTask'
);
function index() {
$tasks = ClassInfo::subclassesFor('BuildTask');
if(Director::is_cli()) {
echo "Tasks available:\n\n";
foreach($tasks as $task) echo " * $task: sake dev/tasks/$task\n";
} else {
echo "
Tasks available
\n";
echo "";
foreach($tasks as $task) {
echo "- $task
\n";
}
echo "
";
}
}
function runTask($request) {
$TaskName = $request->param('TaskName');
if (class_exists($TaskName) && is_subclass_of($TaskName, 'BuildTask')) {
if(Director::is_cli()) echo "Running task '$TaskName'...\n\n";
else echo "Running task '$TaskName'...
\n";
$task = new $TaskName();
if (!$task->isDisabled()) $task->run($request);
} else {
echo "Build task '$TaskName' not found.";
if(class_exists($TaskName)) echo " It isn't a subclass of BuildTask.";
echo "\n";
}
}
}
?>