Merge pull request #6566 from andrewandante/feat/backport_buildtask_segment_config

add segment config var to buildtask
This commit is contained in:
Daniel Hensby 2017-01-25 11:27:02 +00:00 committed by GitHub
commit 7c79374704
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,
);
}