From 2e1eb4afad51d714ebd96deba9337f9e8495e995 Mon Sep 17 00:00:00 2001 From: Andrew Aitken-Fincham Date: Wed, 25 Jan 2017 09:22:20 +0000 Subject: [PATCH] add segment config var to buildtask --- dev/BuildTask.php | 8 ++++++++ dev/TaskRunner.php | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dev/BuildTask.php b/dev/BuildTask.php index c374b45a5..c588dc33d 100644 --- a/dev/BuildTask.php +++ b/dev/BuildTask.php @@ -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. diff --git a/dev/TaskRunner.php b/dev/TaskRunner.php index c09a72d73..0c8d640f9 100644 --- a/dev/TaskRunner.php +++ b/dev/TaskRunner.php @@ -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, ); }