Stable release of v3.2.0-beta6

Fix the plug-in installer script builder bug #1068. Fix Event triggers for Joomla 4 and 5 builds.
This commit is contained in:
2024-03-11 18:14:39 +02:00
parent f5f308dbf2
commit 7448403a46
9 changed files with 70 additions and 43 deletions

View File

@ -26,13 +26,20 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
class Event implements EventInterface
{
/**
* event plugin trigger switch
* event plug-in trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* The application to trigger and event TODO
*
* @since 3.2.0
*/
protected $dispatcher;
/**
* Constructor
*
@ -60,6 +67,8 @@ class Event implements EventInterface
}
}
}
$this->dispatcher = Factory::getApplication();
}
/**
@ -77,22 +86,14 @@ class Event implements EventInterface
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
// Get the dispatcher.
$dispatcher = \JEventDispatcher::getInstance();
// Trigger this compiler event.
$results = $dispatcher->trigger($event, $data);
// Check for errors encountered while trigger the event
if (count((array) $results) && in_array(false, $results, true))
try
{
// Get the last error.
$error = $dispatcher->getError();
if (!($error instanceof \Exception))
{
throw new \Exception($error);
}
// Trigger this compiler event.
$results = $this->dispatcher->triggerEvent($event, $data ?? []);
}
catch (\Exception $e)
{
throw new \Exception("Error processing event '$event': " . $e->getMessage());
}
}
}

View File

@ -12,6 +12,7 @@
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaFour;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use Joomla\CMS\Plugin\PluginHelper;
use VDM\Joomla\Utilities\Component\Helper;
@ -26,13 +27,20 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
final class Event implements EventInterface
{
/**
* event plugin trigger switch
* event plug-in trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* The application to trigger and event TODO
*
* @since 3.2.0
*/
protected $dispatcher;
/**
* Constructor
*
@ -60,6 +68,8 @@ final class Event implements EventInterface
}
}
}
$this->dispatcher = Factory::getApplication();
}
/**
@ -77,22 +87,14 @@ final class Event implements EventInterface
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
// Get the dispatcher.
$dispatcher = \JEventDispatcher::getInstance();
// Trigger this compiler event.
$results = $dispatcher->trigger($event, $data);
// Check for errors encountered while trigger the event
if (count((array) $results) && in_array(false, $results, true))
try
{
// Get the last error.
$error = $dispatcher->getError();
if (!($error instanceof \Exception))
{
throw new \Exception($error);
}
// Trigger this compiler event.
$results = $this->dispatcher->triggerEvent($event, $data ?? []);
}
catch (\Exception $e)
{
throw new \Exception("Error processing event '$event': " . $e->getMessage());
}
}
}