add segment config var to buildtask

This commit is contained in:
Andrew Aitken-Fincham 2017-01-25 09:22:20 +00:00
parent d9cffe5f53
commit 2e1eb4afad
2 changed files with 13 additions and 4 deletions

View File

@ -12,6 +12,14 @@
*/
abstract class BuildTask extends Object {
/**
* Set a custom url segment (to follow dev/tasks/)
*
* @config
* @var string
*/
private static $segment = null;
/**
* @var bool $enabled If set to FALSE, keep it from showing in the list
* and from being executable through URL or CLI.

View File

@ -103,17 +103,18 @@ class TaskRunner extends Controller {
// remove the base class
array_shift($taskClasses);
if($taskClasses) foreach($taskClasses as $class) {
foreach($taskClasses as $class) {
if (!$this->taskEnabled($class)) continue;
$singleton = singleton($class);
$desc = (Director::is_cli())
? Convert::html2raw(singleton($class)->getDescription())
: singleton($class)->getDescription();
? Convert::html2raw($singleton->getDescription())
: $singleton->getDescription();
$availableTasks[] = array(
'class' => $class,
'title' => singleton($class)->getTitle(),
'segment' => str_replace('\\', '-', $class),
'segment' => $singleton->config()->segment ?: str_replace('\\', '-', $class),
'description' => $desc,
);
}