Update ContentReviewEmails disable static name and logic

This commit is contained in:
Julian Thomson 2023-03-15 16:22:20 +13:00
parent 14d19cc282
commit 3e5da529b3
2 changed files with 7 additions and 7 deletions

View File

@ -30,9 +30,9 @@ and previous reviews in the same view, but cannot change anything.
## Disable for pre-prod environments
The sending of emails can be disabled for pre-production environments. This may be needed if a production database is restored to a UAT environment.
The sending of emails can be disabled. This feature may be needed for example, if a production database is restored to a UAT environment.
```
SilverStripe\ContentReview\Tasks\ContentReviewEmails:
disablePreProd: true
send_emails: false
```

View File

@ -4,7 +4,6 @@ namespace SilverStripe\ContentReview\Tasks;
use Page;
use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\Control\Director;
use SilverStripe\Control\Email\Email;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Dev\BuildTask;
@ -22,15 +21,16 @@ use SilverStripe\View\SSViewer;
*/
class ContentReviewEmails extends BuildTask
{
private static $disablePreProd = false;
private static $send_emails = true;
/**
* @param HTTPRequest $request
*/
public function run($request)
{
// If the $disablePreProd static has been set to true, don't run the task
if (!Director::isLive() && $this->config()->get('disablePreProd')) {
echo 'The Content review task has been disabled for pre-prod environments';
// If the $send_emails static has been set to false, don't run the task
if (!$this->config()->get('send_emails')) {
echo 'The Content review task has been disabled';
exit;
}