No Code Attached Yet
avatar alikon
alikon
19 Jul 2021

Steps to reproduce the issue

try to reuse code from CLI, for example notify superuser

// Push a notification to the site's super users
/** @var MessageModel $messageModel */
$messageModel = $this->app->bootComponent('com_messages')->getMVCFactory()->createModel('Message', 'Administrator');

//.... do something

$_SERVER['HTTP_HOST'] = 'fake.url';
$username= 'fakeuser';

// Load com_message's language
$language = Factory::getLanguage();
$language->load('com_messages', JPATH_ADMINISTRATOR, 'en-GB', false, true);
$language->load('com_messages', JPATH_ADMINISTRATOR, null, true);

$messageModel->notifySuperUsers(
	Text::_('PLG_SYSTEM_PRIVACYCONSENT_NOTIFICATION_USER_PRIVACY_EXPIRED_SUBJECT'),
	Text::sprintf('PLG_SYSTEM_PRIVACYCONSENT_NOTIFICATION_USER_PRIVACY_EXPIRED_MESSAGE', $username)
);

Expected result

able to call $messageModel->notifySuperUsers from CLI

Actual result

image

System information (as much as possible)

j4

Additional comments

as a quick dirty fix
i've just added this method to ConsoleApplication.php https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Application/ConsoleApplication.php

	public static function getRouter($name = null, array $options = array())
	{
		$app = Factory::getApplication();

		if (!isset($name))
		{
			$name = $app->getName();
		}

		$options['mode'] = $app->get('sef');

		return Router::getInstance($name, $options);
	}

is there a better way ?

avatar alikon alikon - open - 19 Jul 2021
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Jul 2021
avatar alikon alikon - change - 17 Dec 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-12-17 09:57:29
Closed_By alikon
Labels Added: No Code Attached Yet
Removed: ?
avatar alikon alikon - close - 17 Dec 2021
avatar alikon
alikon - comment - 17 Dec 2021

fixed with #36332

Add a Comment

Login with GitHub to post a comment