diff --git a/components/com_ajax/ajax.php b/components/com_ajax/ajax.php index 3915ebb837881..77dc5c1f87d9b 100644 --- a/components/com_ajax/ajax.php +++ b/components/com_ajax/ajax.php @@ -10,6 +10,8 @@ defined('_JEXEC') or die; +use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\GenericEvent; use Joomla\CMS\Event\Plugin\AjaxEvent; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -130,11 +132,17 @@ $dispatcher = $app->getDispatcher(); $group = $input->get('group', 'ajax'); $eventName = 'onAjax' . ucfirst($input->get('plugin', '')); + + // @TODO: plugin plg_system_webauthn and all other plugins should use common AjaxEvent + $event = AbstractEvent::create($eventName, ['subject' => $app]); + + if ($event instanceof GenericEvent) { + $event = new AjaxEvent($eventName, ['subject' => $app]); + } + PluginHelper::importPlugin($group, null, true, $dispatcher); - $results = $dispatcher->dispatch($eventName, new AjaxEvent($eventName, [ - 'subject' => $app, - ]))->getArgument('result', []); + $results = $dispatcher->dispatch($eventName, $event)->getArgument('result', []); } catch (Throwable $e) { $results = $e; }