Closed Mister-42 closed 3 years ago
What's the benefit? How would the widget or whatever package use the bootstrap then? Would that mean that we should maintain 100% compatibility of APIs of version 4 and version 5?
A dev can determine what version is installed apply accordingly. The API can change however you want it, it is up to the devs to implement it corrently for all versions if they choose to do so.
if (class_exists('Yiisoft\Yii\Bootstrap4\Accordion')) {
// Show version v4
} elseif (class_exists('Yiisoft\Yii\Bootstrap5\Accordion')) {
// Show version v5
}
or if the API is still the same this can be used
$version = class_exists('Yiisoft\Yii\Bootstrap4\Nav') ? 'Bootstrap4' : 'Bootstrap5';
$breadcrumbs = '\Yiisoft\Yii\\' . $version . '\Breadcrumbs';
echo $breadcrumbs::widget()
->encodeLabels(false)
->homeLink(['label' => _('Home'), 'url' => $url->generate('site/index'), 'class' => 'text-decoration-none'])
->links($this->params['breadcrumbs'] ?? []);
Ugly examples, but I think you get the drift.
The only alternative I have as a dev now is to create 2 different packages for each version.
Sounds alright. Let's do it in both bootstrap4 and bootstrap5.
Hello devs,
Would you please consider creating a virtual package
yii-bootstrap
, that bothyii-bootstrap4
andyii-bootstrap5
'provide' to? That way we can requireyii-bootstrap
and leave it up to the individual devs to choose a version.