tastaturberuf / contao-entity-attributes-bundle
Use PHP 8+ Attributes to configure the DCA
Fund package maintenance!
Tastaturberuf
paypal.me/tastaturberuf
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 0
Type:contao-bundle
pkg:composer/tastaturberuf/contao-entity-attributes-bundle
Requires
- php: ^8.0
- codefog/contao-haste: ^4.24
- contao-community-alliance/meta-palettes: ^2.0
- contao/core-bundle: ^4.9
- doctrine/annotations: ^1.11
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2026-02-06 16:03:25 UTC
README
Usage:
Set the mapping type to attribute and define where your entities are.
# config/services.yaml
doctrine:
orm:
mappings:
App:
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
Tag your entities with entity.datacontainer.
# config/services.yaml
App\Entity\:
resource: '../src/Entity/'
tags: ['entity.datacontainer']
Minimal configuration
use Doctrine\ORM\Mapping as ORM;
use Tastaturberuf\ContaoEntityAttributesBundle\Attribute as DCA;
#[ORM\Entity]
#[ORM\Table('tl_my_table_name')]
#[DCA\DataContainer]
class MyEntity
{
}
Exemplary configuration
use Doctrine\ORM\Mapping as ORM;
use Tastaturberuf\ContaoEntityAttributesBundle\Attribute as DCA;
#[ORM\Entity]
#[ORM\Table('my_entity')]
#[DCA\DataContainer]
#[DCA\Label(fields: ['id', 'tstamp', 'name', 'alias'], showColumns: true)]
#[DCA\Palettes(legends: ['title', 'config', 'custom'])]
#[DCA\GlobalOperationAll]
#[DCA\OperationEdit]
#[DCA\OperationDelete]
#[DCA\OperationShow]
// there are more Attributes available
class MyEntity
{
#[DCA\Field(exclude: false)]
private int $id;
#[ORM\Column('my_custom_name', nullable: true)]
#[DCA\Field(search: true, sorting: true)]
#[DCA\Palette('title')]
// there are more Attributes available
private string $name;
}
Custom properties
Just type your custom properties as PHP 8 named params.
use Tastaturberuf\ContaoEntityAttributesBundle\Attribute as DCA;
#[DCA\DataContainer(my_custom_key: 'my_custom_value')]
class myEntity
{
}
Good to know
Field::$excludeis defaulttrueSorting::$panelLayoutdefault is'filter;sort,search,limit'- don't use the
$__custom_propertiesparameter, just write your [custom properties](#Custom properties).
To do
- Write a basic usage documentation.
- Add helper properties like
w50: truefor fields with most used configurations. - Create CompilerPass for
EntityDataContainerInterfaceto tag Entities automatically. - Refactor the
PaletteandPalettesAttribute for better handling. Maybe without MetaPalettes requirement. - Configure the field evaluation from Doctrine Mapping like
minLength,maxLengthetc.