Adjust isEnabled method (#10801)

* Adjust isEnabled method to use config values if present, adjust dev.yml to have a default_enabled key, add is_enabled as a private property for deprecation in cms 6

* remove default_enabled flag again, adjust comments as suggested, remove method signature from isEnabled, fix typo, adjust logic and add fallback value for isEnabled as true

* adjust isEnabled method, change static:: to ->enabled as the property is not actually static

---------

Co-authored-by: Kevin Gröger <k.groeger@headtrip.eu>
This commit is contained in:
kevingroeger 2023-06-08 02:22:14 +02:00 committed by GitHub
parent 86917ce291
commit 30cd4047df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Dev;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injectable;
@ -32,9 +33,16 @@ abstract class BuildTask
*/
private static $segment = null;
/**
* Make this non-nullable and change this to `bool` in CMS6 with a value of `true`
* @var bool|null
*/
private static ?bool $is_enabled = null;
/**
* @var bool $enabled If set to FALSE, keep it from showing in the list
* and from being executable through URL or CLI.
* @deprecated - remove in CMS 6 and rely on $is_enabled instead
*/
protected $enabled = true;
@ -64,7 +72,12 @@ abstract class BuildTask
*/
public function isEnabled()
{
return $this->enabled;
$isEnabled = $this->config()->get('is_enabled');
if ($isEnabled === null) {
return $this->enabled;
}
return $isEnabled;
}
/**