Skip to main content
added 7 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can trigger the event through the application:

$res = Joomla\CMS\Factory::getApplication()->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$res = $dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can trigger the event through the application:

$res = Joomla\CMS\Factory::getApplication()->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can trigger the event through the application:

$res = Joomla\CMS\Factory::getApplication()->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$res = $dispatcher->dispatch('onCheckAnswer', $event);
Correct legacy code
Source Link
Sharky
  • 12k
  • 8
  • 23

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can gettrigger the dispatcherevent through the application:

$dispatcher$res = Joomla\CMS\Factory::getApplication()->getDispatcher();
$res = $dispatcher->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can get the dispatcher through application:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$res = $dispatcher->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can trigger the event through the application:

$res = Joomla\CMS\Factory::getApplication()->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);
added 2 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can get the dispatcher through application:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$res = $dispatcher->triggerEvent('onCheckAnswer', $post['recaptcha_response_field'][$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can get the dispatcher through application:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$res = $dispatcher->triggerEvent('onCheckAnswer', $post['recaptcha_response_field']);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);

The ideal way is to have dependencies injected into your objects. Event dispatcher is registered with the global service container so you can fetch it when registering your component services in provider.php. However, there isn't a good way to pass it down to MVC elements without a custom MVC factory. Core components don't use anything like that yet.

That said, if you just want to get your code working, you can get the dispatcher through application:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$res = $dispatcher->triggerEvent('onCheckAnswer', [$post['recaptcha_response_field']]);

Note that this method is already deprecated and will be removed in 5.0. Going forward, an event object should be created and passed to dispatcher's dispatch() method:

$dispatcher = Joomla\CMS\Factory::getApplication()->getDispatcher();
$event = new Joomla\Event\Event('onCheckAnswer', [$post['recaptcha_response_field']]);
$dispatcher->dispatch('onCheckAnswer', $event);
Post Undeleted by Sharky
added 391 characters in body
Source Link
Sharky
  • 12k
  • 8
  • 23
Loading
Post Deleted by Sharky
Source Link
Sharky
  • 12k
  • 8
  • 23
Loading