Skip to content

Commit b4626db

Browse files
committed
refactor
1 parent 14755f6 commit b4626db

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

plugins/behaviour/compat/src/Extension/Compat.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
namespace Joomla\Plugin\Behaviour\Compat\Extension;
1212

1313
use Joomla\CMS\Event\Application\AfterInitialiseDocumentEvent;
14+
use Joomla\CMS\Event\Application\AfterRouteEvent;
15+
use Joomla\CMS\Factory;
1416
use Joomla\CMS\Plugin\CMSPlugin;
1517
use Joomla\Event\DispatcherInterface;
1618
use Joomla\Event\Priority;
1719
use Joomla\Event\SubscriberInterface;
18-
use Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap;
1920

2021
// phpcs:disable PSR1.Files.SideEffects
2122
\defined('_JEXEC') or die;
@@ -44,6 +45,7 @@ public static function getSubscribedEvents(): array
4445
*/
4546
return [
4647
'onAfterInitialiseDocument' => ['onAfterInitialiseDocument', Priority::HIGH],
48+
'onAfterRoute' => ['onAfterRoute', Priority::HIGH],
4749
];
4850
}
4951

@@ -84,24 +86,36 @@ public function __construct(DispatcherInterface $dispatcher, array $config = [])
8486
}
8587

8688
/**
87-
* We run as early as possible, this should be the first event
89+
* The after Route logic
8890
*
89-
* @param AfterInitialiseDocumentEvent $event
91+
* @param AfterRouteEvent $event
9092
* @return void
9193
*
92-
* @since 5.0.0
94+
* @since __DEPLOY_VERSION__
9395
*/
94-
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
96+
public function onAfterRoute($event)
9597
{
9698
/**
9799
* Load the deprecated HTMLHelper classes/functions
98100
* likely be removed in Joomla 7.0
99101
*/
100102
if ($this->params->get('html_helpers', '1')) {
101103
// Restore HTMLHelper::Bootstrap('framework')
102-
new Bootstrap();
104+
Factory::getContainer()->get(\Joomla\CMS\HTML\Registry::class)
105+
->register('bootstrap', \Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap::class, true);
103106
}
107+
}
104108

109+
/**
110+
* We run as early as possible, this should be the first event
111+
*
112+
* @param AfterInitialiseDocumentEvent $event
113+
* @return void
114+
*
115+
* @since 5.0.0
116+
*/
117+
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
118+
{
105119
/**
106120
* Load the es5 assets stubs, they are needed if an extension
107121
* directly uses a core es5 asset which has no function in Joomla 5+

plugins/behaviour/compat/src/HTMLHelper/Bootstrap.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@
88
namespace Joomla\Plugin\Behaviour\Compat\HTMLHelper;
99

1010
use Joomla\CMS\Factory;
11-
use Joomla\CMS\HTML\HTMLHelper;
11+
use Joomla\CMS\HTML\Helpers\Bootstrap as OriginalBootstrap;
1212

13-
class Bootstrap
14-
{
15-
public function __construct()
16-
{
17-
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
18-
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap::framework');
19-
}
20-
}
2113

14+
class Bootstrap extends OriginalBootstrap
15+
{
2216
/**
2317
* Method to load the ALL the Bootstrap Components
2418
*

0 commit comments

Comments
 (0)