I have a CLI-extension used in a plugin, but need to call a method in the plugin’s main .php
-file to avoid recreating a method in the CLI. I declared the namespace of the plugin, use Grav\Plugin\TwigFeedsPlugin;
, and call it as such:
$call = new TwigFeedsPlugin;
$call = $call->call();
$this->output->writeln($call);
But this returns an error:
PHP Warning: Missing argument 1 for Grav\Common\Plugin::__construct(), called in C:\Caddy\grav\user\plugins wigfeeds\cli\BuildTwigFeedsCacheCommand.ph p on line 37 and defined in C:\Caddy\grav\system\src\Grav\Common\Plugin.php on line 70
PHP Fatal error: Uncaught TypeError: Argument 2 passed to Grav\Common\Plugin::__construct() must be an instance of Grav\Common\Grav, none given, called in C:\Caddy\grav\user\plugins wigfeeds\cli\BuildTwigFeedsCacheCommand.ph p on line 37 and defined in C:\Caddy\grav\system\src\Grav\Common\Plugin.php:70
How can I call a method from the plugin’s class from a CLI-file? It would reduce quite a lot of overhead as they share some methods.