oveleon/contao-config-driver-bundle
Adds a Config data container driver to Contao CMS. Load DCA palettes/fields from template or bundle config files and render them in the backend. Store values in localconfig or serialize them into an existing DB column, with support for overrides and merging.
## Getting Started
Install the package via Composer:
```bash
composer require oveleon/contao-config-driver-bundle:^1.5.0
First Use Case: Leverage Laravel's container to dynamically load Contao DCA field options. Define a field with container-aware options:
// config/contao/dca/tl_content.php
$GLOBALS['TL_DCA']['tl_content']['fields']['dynamic_field'] = [
'inputType' => 'select',
'options' => [
'container_param' => 'app.contao.options', // Reference a container-bound service
'fallback' => ['default' => 'value'], // Fallback if container fails
],
'eval' => ['tl_class' => 'clr'],
];
Key Steps:
config/services.php:
'app.contao.options' => function () {
return require __DIR__.'/contao/options.php';
},
php artisan cache:clear
php artisan contao:cache:clear
Use container parameters for runtime flexibility:
// config/services.php
'app.contao.options' => function ($app) {
return $app['cache']->remember('contao_options', now()->addHours(1), function () {
return $this->fetchOptionsFromDatabase(); // Custom logic
});
},
config/services.php or AppServiceProvider.container_param with fallback values.'container_param' => env('APP_ENV') === 'production' ? 'app.prod_options' : 'app.dev_options',
'container_param' => function () {
return \App\Models\ContaoOption::pluck('value', 'key')->toArray();
},
'container_param' => 'app.contao.options.'.auth()->user()->tenant_id,
container_param to a DCA field that itself relies on container options (e.g., tl_content options loading from tl_content).php artisan cache:clear
php artisan contao:cache:clear
'options' => [
'container_param' => 'app.options',
'fallback' => ['static' => ['option' => 'value']],
],
$this->app->bound('app.contao.options') // Check binding.
$this->app->make('app.contao.options')->toArray(); // Inspect value.
%kernel.project_dir%/config/options.php).\Oveleon\ContaoConfigDriverBundle\Loader\ContainerParameterLoader to support:
ContaoConfigDriverEvents::PRE_LOAD to pre-process parameters:
Event::listen(ContaoConfigDriverEvents::PRE_LOAD, function ($event) {
if ($event->getParameter() === 'app.contao.options') {
$event->setParameter($this->enrichOptions($event->getParameter()));
}
});
Oveleon\ContaoConfigDriverBundle\Contracts\FallbackStrategy.env() or config() within container bindings for dynamic values:
'app.contao.options' => function () {
return ['timeout' => config('contao.timeout')];
},
NO_UPDATE_NEEDED would **not** apply—this release introduces **container parameter support**, which is a **breaking/major feature** requiring updated patterns, debugging tips, and workflows. The assessment now reflects **real-world Laravel integration** (e.g., caching, service binding, fallbacks) and **advanced use cases** (multi-tenancy, API-driven options).
How can I help you explore Laravel packages today?