I am converting some Joomla 3 CLI applications to use the Joomla Console and this message is causing my new CLI's to fail. There are various entries in Joomla tracker relating to similar issues where core functions are not handling being in the Cli Application correctly but I haven't found anything looks like a permanent fix.
In this case I am using old style call to get a model where I am not in position to use a newer method to access my model until a related component is upgraded to J4 where the problem may no longer exist.
BaseDatabaseModel::getInstance('Inventory', 'InventoryModel')
which is then invoking the plugins which is where the actual call to the template function is coming from \libraries\src\Plugin\PluginHelper.php
$templateObj = Factory::getApplication()->getTemplate(true);
I have a work around that involves modifying the core code of \libraries\src\Application\ConsoleApplication.php
and adding a simple function to handle the call to the method that does not exist.
public function getTemplate() { return false; }
This is not something I want to have to do and remember to do each time I do an update.
In the earlier Joomla 3 version of my CLI's the above line of code was added to the bottom of the class to handle the same/similar issue, effectively this is what I am doing in the ConsoleApplication class.
My question is can anyone provide a solution or direct me to a solution that doesn't involve modifying the core code?
There are issues open on Joomla's Issue Tracker that refer to this issue like https://github.com/joomla/joomla-cms/pull/39550, https://github.com/joomla/joomla-cms/pull/38222 and https://github.com/joomla/joomla-cms/pull/38585 in the pluginHelper and the fileLayout classes so i am hoping any improved work around is not going to be required for too long.