mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
bf9f349210
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60276 467b73ca-7a2a-4603-9d3b-597d59a354a9
45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage dev
|
|
*/
|
|
class TaskRunner extends Controller {
|
|
|
|
static $url_handlers = array(
|
|
'' => '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 "<h1>Tasks available</h1>\n";
|
|
echo "<ul>";
|
|
foreach($tasks as $task) {
|
|
echo "<li><a href=\"$task\">$task</a></li>\n";
|
|
}
|
|
echo "</ul>";
|
|
}
|
|
}
|
|
|
|
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 "<h1>Running task '$TaskName'...</h1>\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";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
?>
|