From 518e8101d65650a1050b9c8588750795b6bbb239 Mon Sep 17 00:00:00 2001 From: Nicolaas Date: Sat, 27 Mar 2021 22:12:14 +1300 Subject: [PATCH] MINOR: adding link to BuildTask This makes it easier to access dev/tasks from various places in, for example, the CMS. In further commits, this can also be used in other places so that there is one source of truth for the link for a BuildTask. --- src/Dev/BuildTask.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Dev/BuildTask.php b/src/Dev/BuildTask.php index 6f6423ccd..42f5567e3 100644 --- a/src/Dev/BuildTask.php +++ b/src/Dev/BuildTask.php @@ -6,6 +6,7 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injectable; +use SilverStripe\Control\Director; /** * Interface for a generic build task. Does not support dependencies. This will simply @@ -82,4 +83,16 @@ abstract class BuildTask { return $this->description; } + + /** + * @return string e.g. /dev/tasks/MyTask-In-Full + */ + public function Link() : string + { + $link = $this->Config()->get('segment'); + if (! $link) { + $link = str_replace('\\', '-', static::class); + } + return Director::absoluteUrl('dev/tasks/') . $link; + } }