Skip to content

Commit a8c70c2

Browse files
committed
Add forwards compatibility for the old mooRainbow color picker
1 parent 07628d4 commit a8c70c2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
"require": {
5656
"php": "^8.1",
5757
"ext-json": "*",
58+
"contao-components/colorpicker": "^1.5",
5859
"contao/core-bundle": "^4.13 || ^5.0",
60+
"symfony/asset": "^5.4 || ^6.0",
5961
"symfony/config": "^5.4 || ^6.0",
6062
"symfony/console": "^5.4 || ^6.0",
6163
"symfony/dependency-injection": "^5.4 || ^6.0",

src/EventListener/Contao/InitializeSystem.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323

2424
namespace MenAtWork\MultiColumnWizardBundle\EventListener\Contao;
2525

26+
use Contao\CoreBundle\ContaoCoreBundle;
2627
use Contao\Environment;
2728
use Contao\Input;
2829
use Contao\System;
2930
use MenAtWork\MultiColumnWizardBundle\Service\ContaoApiService;
31+
use Symfony\Component\Asset\Packages;
3032

3133
/**
3234
* Class InitializeSystem
@@ -38,12 +40,19 @@ class InitializeSystem
3840
*/
3941
private ContaoApiService $contaoApi;
4042

43+
/**
44+
* @var Packages
45+
*/
46+
private Packages $packages;
47+
4148
/**
4249
* @param ContaoApiService $contaoApi
50+
* @param Packages $packages
4351
*/
44-
public function __construct(ContaoApiService $contaoApi)
52+
public function __construct(ContaoApiService $contaoApi, Packages $packages)
4553
{
4654
$this->contaoApi = $contaoApi;
55+
$this->packages = $packages;
4756
}
4857

4958
/**
@@ -70,6 +79,12 @@ public function addSystemNecessaryThings(): void
7079
$GLOBALS['TL_CSS']['multicolumnwizard'] = System::getContainer()->get('kernel')->isDebug()
7180
? 'bundles/multicolumnwizard/css/multicolumnwizard_src.css'
7281
: 'bundles/multicolumnwizard/css/multicolumnwizard.css';
82+
83+
// Load the old mooRainbow picker in Contao 5.5
84+
if (version_compare(ContaoCoreBundle::getVersion(), '5.5', '>=')) {
85+
$GLOBALS['TL_JAVASCRIPT']['mooRainbow'] = $this->packages->getUrl('js/mooRainbow.min.js', 'contao-components/colorpicker');
86+
$GLOBALS['TL_CSS']['mooRainbow'] = $this->packages->getUrl('css/mooRainbow.min.css', 'contao-components/colorpicker');
87+
}
7388
}
7489

7590
/**

src/Resources/config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
public: true
1111
arguments:
1212
- '@MenAtWork\MultiColumnWizardBundle\Service\ContaoApiService'
13+
- '@assets.packages'
1314

1415
MenAtWork\MultiColumnWizardBundle\EventListener\Contao\LoadDataContainer:
1516
public: true

0 commit comments

Comments
 (0)