Skip to content

Commit

Permalink
DOC Document changes to CLI interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Sep 4, 2024
1 parent a14f291 commit 20ebfd6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions en/02_Developer_Guides/09_Security/00_Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
```
Expand Down

0 comments on commit 20ebfd6

Please sign in to comment.