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)
);
able to call $messageModel->notifySuperUsers
from CLI
j4
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 ?
Labels |
Added:
?
|
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: ? |
fixed with #36332