From c48d5b1fd2e5974f48d9ba08476c62b070aa830e Mon Sep 17 00:00:00 2001 From: bnomei Date: Thu, 12 Sep 2024 14:55:01 +0200 Subject: [PATCH] :sparkles: force argument for call command 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 --- commands/call.php | 8 +++++++- composer.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/commands/call.php b/commands/call.php index cc0091e..622965e 100644 --- a/commands/call.php +++ b/commands/call.php @@ -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'); @@ -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 { diff --git a/composer.json b/composer.json index 1f327c2..9c91fb9 100644 --- a/composer.json +++ b/composer.json @@ -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",