Skip to content

Commit

Permalink
Add docs on custom entity collections for attributed entities (#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickygerritsen authored Nov 15, 2024
1 parent 1694ec7 commit bdffd1e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Since Shopware v6.6.3.0, it has been possible to register entities via PHP attri

First, you need to define your entity. This is done by creating a new class extending `Entity` and adding the `Entity` attribute to it. The `name` parameter denotes the name of the entity. It is required and must be unique.

You can also supply the entity collection class to use for this entity, by specifying the `collectionClass` parameter. The default `EntityCollection` class is used if none is specified.

You have to define a primary key. The primary key is defined by adding the `PrimaryKey` attribute to a property. In theory, the primary key can be of any type, but it is recommended to use a `UUID`.

```php
Expand All @@ -23,7 +25,7 @@ namespace Examples;
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\Attribute\Entity as EntityAttribute;

#[EntityAttribute('example_entity')]
#[EntityAttribute('example_entity', collectionClass: ExampleEntityCollection::class)]
class ExampleEntity extends Entity
{
#[PrimaryKey]
Expand Down

0 comments on commit bdffd1e

Please sign in to comment.