Open dan8551 opened 4 years ago
Yes it’s nasty. Pluto itself isn’t dependent on either Bootstrap3 or Bootstrap4, but softark/yii2-dual-listbox depends on bootstrap3. It would be possible to change softark’s code, but that’s against my principles. Therefore, in my sites, I use Yii::$container->setDefinitions to redirect yii\bootstrap\BootstrapAsset to yii\bootstrap4\BootstrapAsset. Same for BootstrapPluginAsset. This solves the problem generally. Lots of extensions still depend on Bootstrap3.
Sjaak Priester
sjaak@sjaakpriester.nl mailto:sjaak@sjaakpriester.nl
Van: dan8551 notifications@github.com Verzonden: zaterdag 28 maart 2020 21:36 Aan: sjaakp/yii2-pluto yii2-pluto@noreply.github.com CC: Subscribed subscribed@noreply.github.com Onderwerp: [sjaakp/yii2-pluto] Bootstrap 4 (#18)
The module has the option to switch to Bootstrap V4 but due to dependencies, cannot properly perform as V3 support is still required which completely changes the layout, this is due to V3 and V4 being loaded on the same page.
Please can you change dependencies to V4 support?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sjaakp/yii2-pluto/issues/18 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKTXVRARKQ6WM76MFAENDDRJZNT5ANCNFSM4LVWQ43A . https://github.com/notifications/beacon/ABKTXVTW2QLQ3UUJIRQLK4LRJZNT5A5CNFSM4LVWQ43KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IZFNONQ.gif
Hi sjakkp, could you provide an example on how to use Yii::$container->setDefinitions I'm getting errors of bootstrap dependency for example in/pluto/role/create:
Failed to instantiate component or class "yii\bootstrap\BootstrapAsset"
Caused by: ReflectionException
Class yii\bootstrap\BootstrapAsset does not exist
in /home/xxxx/vendor/yiisoft/yii2/di/Container.php at line 447
Thank you!
Have you installed "yiisoft/yii2-bootstrap": "*" and "yiisoft/yii2-bootstrap4 in your composer.json under the require section and updated composer?
The setDefinition function on Github
public function setDefinitions(array $definitions)
{
foreach ($definitions as $class => $definition) {
if (is_array($definition) && count($definition) === 2 && array_values($definition) === $definition && is_array($definition[1])) {
$this->set($class, $definition[0], $definition[1]);
continue;
}
$this->set($class, $definition); //set command
}
}
As you can see it uses the set command here for each occurrence of a definition. If you are just wanting to setup one definition you can just use the set command. Where? In the first index file .. that sits in your root or web folder. This ensures that it will be implemented from the very beginning.
As Sjaak has suggested here I use the following command to overcome the GridView not displaying pagination css at the bottom according to issue 4 here using the following command in your index file.
Yii::$container->set('yii\widgets\LinkPager', 'yii\bootstrap4\LinkPager');
index.php file
(new yii\web\Application($config));
Yii::$container->set('yii\widgets\LinkPager', 'yii\bootstrap4\LinkPager');
Yii::$app->run();
I initially thought that I would get around this issue by simply changing this extension's yii/grid/Gridview to kartik/grid/GridView which works but this does not help my extension which will be downloadable since it will inherit the bootstrap problem.
So my frontend/config/params section uses Bootstrap 4 as suggested by Kartik.
'bsVersion' => '4.x',
However the old grid does not use Boostrap 4 and this Dependency Injection forces the LinkPager to use boostrap4 linkPager. Admittedly this is a quickfix and I have not had time to isolate the error in the code but this will do for me for the time being.
The module has the option to switch to Bootstrap V4 but due to dependencies, cannot properly perform as V3 support is still required which completely changes the layout, this is due to V3 and V4 being loaded on the same page.
Please can you change dependencies to V4 support?