Skip to content

Commit

Permalink
✨ force argument for call command
Browse files Browse the repository at this point in the history
useful when you want to call methods defined via Kirbys page/user/fileMethods plugin extensions, not just methods defined on a real PHP class model

Signed-off-by: bnomei <[email protected]>
  • Loading branch information
bnomei committed Sep 12, 2024
1 parent 29d738d commit c48d5b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion commands/call.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
'castTo' => 'string',
'required' => true,
],
'force' => [
'longPrefix' => 'force',
'description' => 'Force the call of the method on the mode (like when calling Kirby pageMethods)',
'castTo' => 'bool',
'defaultValue' => false,
],
] + Janitor::ARGS, // page, file, user, site, data, model
'command' => static function (CLI $cli): void {
$method = $cli->arg('method');
Expand All @@ -37,7 +43,7 @@
}

if ($model) {
if (method_exists($model, $method)) {
if ($cli->arg('force') || method_exists($model, $method)) {
if (empty($cli->arg('data'))) {
$result = $model->$method();
} else {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-janitor",
"type": "kirby-plugin",
"version": "4.4.1",
"version": "4.4.2",
"license": "MIT",
"homepage": "https://github.com/bnomei/kirby3-janitor",
"description": "Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob",
Expand Down

0 comments on commit c48d5b1

Please sign in to comment.