Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEXT-0000 - POC php attributes for entities #3688

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

OliverSkroblin
Copy link
Member

@OliverSkroblin OliverSkroblin commented Apr 26, 2024

Goal of this POC is, that you just have to define the entity class and the definition is obsolete:

#[Entity(name: 'my_entity')]
class MyEntity extends EntityStruct
{
    #[Primary(type: 'uuid')]
    public string $id;

    #[Field(type: FieldType::STRING)]
    public string $number;

    #[Field(type: FieldType::PRICE)]
    public ?Price $price = null;

    #[Field(type: FieldType::STRING, translated: true)]
    public ?string $name = null;

    #[Field(type: FieldType::TEXT, translated: true)]
    public ?string $description = null;

    #[Field(type: FieldType::INT, translated: true)]
    public ?int $position = null;

    #[Field(type: FieldType::FLOAT, translated: true)]
    public ?float $weight = null;

    #[Field(type: FieldType::BOOL, translated: true)]
    public ?bool $highlight = null;

    #[Field(type: FieldType::DATETIME, translated: true)]
    public ?\DateTimeImmutable $release = null;

//    #[OneToMany(entity: 'product', field: 'uuid', ref: 'my_entity_id')]
//    public array $products = [];

    #[Fk(entity: 'product', column: 'product_id')]
    public string $productId;

    #[Fk(entity: 'product', column: 'follow_id')]
    public ?string $followId;

    #[ManyToOne(entity: 'product', field: 'product_id', ref: 'id')]
    public ?ProductEntity $product = null;

    #[ManyToMany(entity: 'category', mapping: 'my_entity_categories')]
    public array $categories = [];

    #[OneToOne(entity: 'product', field: 'follow_id', ref: 'id')]
    public ?ProductEntity $follow = null;
}

Copy link

github-actions bot commented Apr 26, 2024

Fails
🚫 Please add tests for your new Migration file
🚫 Please add tests for your new Migration file
🚫 Please add tests for your new Migration file
Warnings
⚠️ The Pull Request doesn't contain any changelog file
⚠️ Please be kind and add unit tests for your new code in these files:
src/Core/Framework/DataAbstractionLayer/Attribute/FieldType.php
src/Core/Framework/DataAbstractionLayer/Attribute/Fk.php
src/Core/Framework/DataAbstractionLayer/Attribute/ManyToMany.php
src/Core/Framework/DataAbstractionLayer/Attribute/ManyToOne.php
src/Core/Framework/DataAbstractionLayer/Attribute/OneToMany.php
src/Core/Framework/DataAbstractionLayer/Attribute/OneToOne.php
src/Core/Framework/DataAbstractionLayer/Attribute/Primary.php
src/Core/Framework/DependencyInjection/CompilerPass/AttributeEntityCompilerPass.php
If you are sure everything is fine with your changes, you can resolve this warning.
You can run `composer make:coverage` to generate dummy unit tests for files that are not covered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant