Skip to content

Commit 9e040aa

Browse files
committed
use own class, use toggler
1 parent 0d3c98f commit 9e040aa

File tree

2 files changed

+54
-29
lines changed

2 files changed

+54
-29
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
5+
* @license GNU General Public License version 2 or later; see LICENSE.txt
6+
*/
7+
8+
namespace Joomla\Plugin\Behaviour\Compat\HTMLHelper;
9+
10+
use Joomla\CMS\Factory;
11+
use Joomla\CMS\HTML\HTMLHelper;
12+
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+
}
21+
22+
/**
23+
* Method to load the ALL the Bootstrap Components
24+
*
25+
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
26+
*
27+
* @param mixed $debug Is debugging mode on? [optional]
28+
*
29+
* @return void
30+
*
31+
* @deprecated 4.0 will be removed in 6.0
32+
* Will be removed without replacement
33+
* Load the different scripts with their individual method calls
34+
*/
35+
public static function framework($debug = null): void
36+
{
37+
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
38+
39+
array_map(
40+
function ($script) use ($wa) {
41+
$wa->useScript('bootstrap.' . $script);
42+
},
43+
['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast']
44+
);
45+
}
46+
}

plugins/behaviour/compat6/src/Extension/Compat6.php

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

1313
use Joomla\CMS\Event\Application\AfterInitialiseDocumentEvent;
14-
use Joomla\CMS\Factory;
15-
use Joomla\CMS\HTML\HTMLHelper;
1614
use Joomla\CMS\Plugin\CMSPlugin;
1715
use Joomla\Event\DispatcherInterface;
1816
use Joomla\Event\Priority;
1917
use Joomla\Event\SubscriberInterface;
18+
use Joomla\Plugin\Behaviour\Compat\HTMLHelper\Bootstrap;
2019

2120
// phpcs:disable PSR1.Files.SideEffects
2221
\defined('_JEXEC') or die;
@@ -101,8 +100,13 @@ public function __construct(DispatcherInterface $dispatcher, array $config = [])
101100
*/
102101
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
103102
{
104-
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
105-
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\Extension\Compat::framework');
103+
/**
104+
* Load the deprecated HTMLHelper classes/functions
105+
* likely be removed in Joomla 7.0
106+
*/
107+
if ($this->params->get('html_helpers', '1')) {
108+
// Restore HTMLHelper::Bootstrap('framework')
109+
new Bootstrap();
106110
}
107111

108112
/**
@@ -117,29 +121,4 @@ public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
117121
->addRegistryFile('media/plg_behaviour_compat6/removed.asset.json');
118122
}
119123
}
120-
121-
/**
122-
* Method to load the ALL the Bootstrap Components
123-
*
124-
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
125-
*
126-
* @param mixed $debug Is debugging mode on? [optional]
127-
*
128-
* @return void
129-
*
130-
* @deprecated 4.0 will be removed in 6.0
131-
* Will be removed without replacement
132-
* Load the different scripts with their individual method calls
133-
*/
134-
public static function framework($debug = null): void
135-
{
136-
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
137-
138-
array_map(
139-
function ($script) use ($wa) {
140-
$wa->useScript('bootstrap.' . $script);
141-
},
142-
['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast']
143-
);
144-
}
145124
}

0 commit comments

Comments
 (0)