Skip to content

Commit

Permalink
Add documentation on using custom field types for attributed entities (
Browse files Browse the repository at this point in the history
  • Loading branch information
nickygerritsen authored Nov 15, 2024
1 parent bdffd1e commit 8eef2be
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ class ExampleEntity extends Entity

All field types are defined in the [`FieldType`](https://github.com/shopware/shopware/blob/trunk/src/Core/Framework/DataAbstractionLayer/Attribute/FieldType.php) class.

If you have a custom field type, you can also specify the FQCN of the field type.

```php
#[EntityAttribute('example_entity')]
class ExampleEntity extends Entity
{
#[PrimaryKey]
#[Field(type: FieldType::UUID)]
public string $id;

#[Field(type: PriceField::class)]
public ?PriceCollection $price = null;

// ...
}
```

We also provide a list of special field types, which implement a specific behavior. They have their own PHP attribute class, for example the `AutoIncrement` or `ForeignKey` field.

```php
Expand Down

0 comments on commit 8eef2be

Please sign in to comment.