diff --git a/dev/BuildTask.php b/dev/BuildTask.php index 1ee8a6820..019c92658 100644 --- a/dev/BuildTask.php +++ b/dev/BuildTask.php @@ -11,12 +11,44 @@ * @package sapphire * @subpackage dev */ -abstract class BuildTask { +abstract class BuildTask extends Object { + + /** + * @var bool $enabled If set to FALSE, keep it from showing in the list + * and from being executable through URL or CLI. + */ + protected $enabled = true; + + /** + * @var string $title Shown in the overview on the {@link TaskRunner} + * HTML or CLI interface. Should be short and concise, no HTML allowed. + */ + protected $title; + + /** + * @var string $description Describe the implications the task has, + * and the changes it makes. Accepts HTML formatting. + */ + protected $description = 'No description available'; abstract function run($request); - public function isDisabled() { - return (property_exists($this, 'Disabled')) ? true : false; + public function isEnabled() { + return $this->enabled; + } + + /** + * @return string + */ + public function getTitle() { + return ($this->title) ? $this->title : $this->class; + } + + /** + * @return string HTML formatted description + */ + public function getDescription() { + return $this->description; } } diff --git a/dev/MigrationTask.php b/dev/MigrationTask.php index 91d443bd3..26a00ef57 100644 --- a/dev/MigrationTask.php +++ b/dev/MigrationTask.php @@ -7,7 +7,11 @@ * @package sapphire * @subpackage dev */ -abstract class MigrationTask extends BuildTask { +class MigrationTask extends BuildTask { + + protected $title = "Database Migrations"; + + protected $description = "Provide atomic database changes (not implemented yet)"; function run($request) { if ($request->param('Direction') == 'down') { @@ -17,9 +21,9 @@ abstract class MigrationTask extends BuildTask { } } - abstract function up(); + function up() {} - abstract function down(); + function down() {} } diff --git a/dev/TaskRunner.php b/dev/TaskRunner.php index c76b37a7e..198f7b840 100644 --- a/dev/TaskRunner.php +++ b/dev/TaskRunner.php @@ -11,35 +11,73 @@ class TaskRunner extends Controller { ); 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 "