silverstripe-framework/src/Dev/BuildTask.php

86 lines
1.9 KiB
PHP
Raw Normal View History

<?php
namespace SilverStripe\Dev;
2016-09-09 08:43:05 +02:00
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
/**
* Interface for a generic build task. Does not support dependencies. This will simply
* run a chunk of code when called.
2014-08-15 08:53:05 +02:00
*
* To disable the task (in the case of potentially destructive updates or deletes), declare
* the $Disabled property on the subclass.
*/
abstract class BuildTask
2016-11-29 00:31:16 +01:00
{
use Injectable;
use Configurable;
use Extensible;
public function __construct()
{
}
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* Set a custom url segment (to follow dev/tasks/)
*
* @config
* @var string
*/
private static $segment = null;
2016-11-29 00:31:16 +01:00
/**
* @var bool $enabled If set to FALSE, keep it from showing in the list
* and from being executable through URL or CLI.
*/
protected $enabled = true;
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* @var string $title Shown in the overview on the {@link TaskRunner}
* HTML or CLI interface. Should be short and concise, no HTML allowed.
*/
protected $title;
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* @var string $description Describe the implications the task has,
* and the changes it makes. Accepts HTML formatting.
*/
protected $description = 'No description available';
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* Implement this method in the task subclass to
* execute via the TaskRunner
*
* @param HTTPRequest $request
2020-12-21 22:23:23 +01:00
* @return void
2016-11-29 00:31:16 +01:00
*/
abstract public function run($request);
2014-08-15 08:53:05 +02:00
2016-12-15 13:20:29 +01:00
/**
* @return bool
*/
2016-11-29 00:31:16 +01:00
public function isEnabled()
{
return $this->enabled;
}
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* @return string
*/
public function getTitle()
{
return $this->title ?: static::class;
2016-11-29 00:31:16 +01:00
}
2014-08-15 08:53:05 +02:00
2016-11-29 00:31:16 +01:00
/**
* @return string HTML formatted description
*/
public function getDescription()
{
return $this->description;
}
}