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 committed Oct 22, 2024
1 parent 7fda13e commit c3b36a2
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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

Check warning on line 79 in guides/plugins/plugins/framework/data-handling/entities-via-attributes.md

View workflow job for this annotation

GitHub Actions / Runner

[LanguageTool] reported by reviewdog 🐶 File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `PHP` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING Raw Output: guides/plugins/plugins/framework/data-handling/entities-via-attributes.md:79:3: File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `PHP` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING
#[EntityAttribute('example_entity')]
class ExampleEntity extends Entity
{
#[PrimaryKey]
#[Field(type: FieldType::UUID)]
public string $id;

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

Check warning on line 88 in guides/plugins/plugins/framework/data-handling/entities-via-attributes.md

View workflow job for this annotation

GitHub Actions / Runner

[LanguageTool] reported by reviewdog 🐶 Add a space between sentences. (SENTENCE_WHITESPACE) Suggestions: ` PriceCollection` Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US Category: TYPOGRAPHY Raw Output: guides/plugins/plugins/framework/data-handling/entities-via-attributes.md:88:12: Add a space between sentences. (SENTENCE_WHITESPACE) Suggestions: ` PriceCollection` Rule: https://community.languagetool.org/rule/show/SENTENCE_WHITESPACE?lang=en-US Category: TYPOGRAPHY

// ...
}
```

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 c3b36a2

Please sign in to comment.