1

I use this code in Joomla 3 component:

$dispatcher = \JEventDispatcher::getInstance();


if (class_exists('PlgSystemFields'))
{
    //detach plugin
    $dispatcher->detach('PlgSystemFields');
}

$return = $this->save2($data);

if (class_exists('PlgSystemFields'))
{
    //register plugin
    $dispatcher->register('', 'PlgSystemFields');
}

I disable the PlgSystemFields plugin for a moment in this code (::detach and ::register function). But in Joomla 4 is this not working. Joomla 4 replace the JEventDespatcher with the 'joomla/event' package. But where are these functions/methods gone?

1 Answer 1

0

The equivalent would be Joomla\Event\DispatcherInterface::removeSubscriber() method but it's not going to work with System - Fields plugin because it does not implement Joomla\Event\SubscriberInterface yet.

There's also Joomla\Event\DispatcherInterface::removeListener() but that isn't going to work as well due to how legacy plugins are implemented in J4.

In short, there is no simple way to achieve this with the plugin in question. It is, however, possible with plugins that have been converted to modern architecture.

3
  • Isn't this against Joomla's backwards compatible policies?
    – Harold
    Jul 19 at 12:54
  • No. Why would it be?
    – Sharky
    Jul 20 at 6:04
  • I am using this in a component, but due to the update to Joomla 4 my component is broken. There is also no comparable alternative.
    – Harold
    Jul 21 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.