Skip to content

Commit b1b8c2a

Browse files
committed
move the code to the compat plg
1 parent a1e4d41 commit b1b8c2a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
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;
1416
use Joomla\CMS\Plugin\CMSPlugin;
1517
use Joomla\Event\DispatcherInterface;
1618
use Joomla\Event\Priority;
@@ -99,6 +101,10 @@ public function __construct(DispatcherInterface $dispatcher, array $config = [])
99101
*/
100102
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
101103
{
104+
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
105+
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\Extension\Compat::framework');
106+
}
107+
102108
/**
103109
* Load the removed assets stubs, they are needed if an extension
104110
* directly uses a core asset from Joomla 5 which is not present in Joomla 6
@@ -111,4 +117,25 @@ public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
111117
->addRegistryFile('media/plg_behaviour_compat6/removed.asset.json');
112118
}
113119
}
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+
public static function framework($debug = null): void
131+
{
132+
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
133+
134+
array_map(
135+
function ($script) use ($wa) {
136+
$wa->useScript('bootstrap.' . $script);
137+
},
138+
['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast']
139+
);
140+
}
114141
}

0 commit comments

Comments
 (0)