Skip to content

Commit ff79615

Browse files
committed
move the code to the compat plg
1 parent a83af47 commit ff79615

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
namespace Joomla\Plugin\Behaviour\Compat\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;
@@ -92,6 +94,10 @@ public function __construct(DispatcherInterface $dispatcher, array $config = [])
9294
*/
9395
public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
9496
{
97+
if (!HTMLHelper::isRegistered('bootstrap.framework')) {
98+
HTMLHelper::register('bootstrap.framework', 'Joomla\Plugin\Behaviour\Compat\Extension\Compat::framework');
99+
}
100+
95101
/**
96102
* Load the es5 assets stubs, they are needed if an extension
97103
* directly uses a core es5 asset which has no function in Joomla 5+
@@ -115,4 +121,25 @@ public function onAfterInitialiseDocument(AfterInitialiseDocumentEvent $event)
115121
->addRegistryFile('media/plg_behaviour_compat/removed.asset.json');
116122
}
117123
}
124+
125+
/**
126+
* Method to load the ALL the Bootstrap Components
127+
*
128+
* If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging.
129+
*
130+
* @param mixed $debug Is debugging mode on? [optional]
131+
*
132+
* @return void
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+
}
118145
}

0 commit comments

Comments
 (0)