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.
This commit is contained in:
Nicolaas 2021-03-27 22:12:14 +13:00 committed by GitHub
parent 504e20320e
commit 518e8101d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -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;
}
}