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']
use Doctrine\ORM\Mapping as ORM;
use Tastaturberuf\ContaoEntityAttributesBundle\Attribute as DCA;
#[ORM\Entity]
#[ORM\Table('tl_my_table_name')]
#[DCA\DataContainer]
class MyEntity
{
}
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;
}
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
{
}
Field::$exclude
is defaulttrue
Sorting::$panelLayout
default is'filter;sort,search,limit'
- don't use the
$__custom_properties
parameter, just write your [custom properties](#Custom properties).
- Write a basic usage documentation.
- Add helper properties like
w50: true
for fields with most used configurations. - Create CompilerPass for
EntityDataContainerInterface
to tag Entities automatically. - Refactor the
Palette
andPalettes
Attribute for better handling. Maybe without MetaPalettes requirement. - Configure the field evaluation from Doctrine Mapping like
minLength
,maxLength
etc.