From 20ebfd6e7f39e6acf0fb9b6f4b477b1a82fa1285 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 28 Aug 2024 17:17:34 +1200 Subject: [PATCH] DOC Document changes to CLI interaction --- en/02_Developer_Guides/09_Security/00_Member.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/en/02_Developer_Guides/09_Security/00_Member.md b/en/02_Developer_Guides/09_Security/00_Member.md index 69ae9f79..f670e41c 100644 --- a/en/02_Developer_Guides/09_Security/00_Member.md +++ b/en/02_Developer_Guides/09_Security/00_Member.md @@ -175,23 +175,24 @@ For example: namespace App\Task; use App\Model\DataRecord; -use BadMethodCallException; -use SilverStripe\Control\Director; use SilverStripe\Dev\BuildTask; +use SilverStripe\HybridExecution\HybridOutput; use SilverStripe\Security\Member; use SilverStripe\Security\Security; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; class CleanRecordsTask extends BuildTask { - public function run($request) + private static bool $can_run_in_browser = false; + + protected function execute(InputInterface $input, HybridOutput $output): int { - if (!Director::is_cli()) { - throw new BadMethodCallException('This task only runs on CLI'); - } $admin = Security::findAnAdministrator(); Member::actAs($admin, function () { DataRecord::get()->filter('Dirty', true)->removeAll(); }); + return Command::SUCCESS; } } ```