PHPackages                             tastaturberuf/contao-datacontainer-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tastaturberuf/contao-datacontainer-bundle

ActiveContao-library[Utility &amp; Helpers](/categories/utility)

tastaturberuf/contao-datacontainer-bundle
=========================================

Define data container configuration with classes/services instead of plain php files

1.0.2(1y ago)27LGPL-3.0-or-laterPHPPHP ^8.1

Since Oct 23Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Tastaturberuf/contao-datacontainer-bundle)[ Packagist](https://packagist.org/packages/tastaturberuf/contao-datacontainer-bundle)[ Fund](https://paypal.me/tastaturberuf)[ GitHub Sponsors](https://github.com/Tastaturberuf)[ RSS](/packages/tastaturberuf-contao-datacontainer-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

[![Version](https://camo.githubusercontent.com/ace652f5ec6af3b9a1342789e580818f43ecc5050d6f98a73337228fc97df431/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746173746174757262657275662f636f6e74616f2d64617461636f6e7461696e65722d62756e646c65)](https://packagist.org/packages/tastaturberuf/contao-datacontainer-bundle)[![Contao Version](https://camo.githubusercontent.com/f5024e559c27263a0f70228aafb35d6b6bcb1d09814e64ae483bc2a2a4d6ec6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6e74616f2d2d76657273696f6e2d253545342e31335f2537432537435f253545352e332d253233463437433030)](https://contao.org)

From Data Container Array to Data Container Class
=================================================

[](#from-data-container-array-to-data-container-class)

Define data container configuration with classes/services instead of plain PHP files.

Why?
----

[](#why)

- Real Dependency Injection
- Don't deal with DCA files and wild names because of the prefixes like `tl_vendor_bundle_tablename`. Just define your table names one time and forget about it later. See advanced usage below.
- Define private callbacks and logic methods in class scope like in Contao 2 or 3.
- Define whatever you need, it's your class.
- It's still possible to override definitions with dca files.

How?
----

[](#how)

A compiler pass tag all classes which implement `Tastaturberuf\ContaoDataContainerBundle\DataContainerInterface` with the tag `tastaturberuf.datacontainer.autoload`. An event listener with the iterable classes listen to the `loadDataContainer` hook and recursive merge the array if the table name matches.

Litte bit of magic: On migrations the table name is unknown if the are no DCA files present. The hook `sqlGetFromDca` take care that the definitions get loaded properly.

All logic happen in this file:

Install
-------

[](#install)

### via Composer

[](#via-composer)

```
composer require tastaturberuf/contao-datacontainer-bundle

```

Basic usage
-----------

[](#basic-usage)

Define a class and implement `DataContainerInterface`.

```
