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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Do not force to use annotations for Sylius project #335

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@Zales0123
Copy link
Member

commented Mar 19, 2019

I open this PR as a base for a discussion about default orm mapping in Sylius-Standard.

Right now we have all Sylius entities extended by default in src/Entity/ directory and mapped with annotations mapping - which is correct and useful, as we have no better option to extend Sylius entities in plugins than providing a trait with new properties, including their mapping. So with such a configuration installing a plugin and extending a Sylius entity is quite hassle-free.

HOWEVER

I, personally, feel bad that I'm a little bit forced to use annotations (I really prefer yml or, even better, xml mapping). I know, I'm not the only one, even though there are not so many of us nowadays 馃彎 馃懘 When I create my own, new resource, in src/Entity/ directory, I'm not able to change the mapping type that I hate, without changing it for all other entities. I was struggling with this issue, as I don't want to force anyone to follow my rules, but on the other hand, I don't want to be forced to anything neither 馃殌 Moreover, a doctrine mapping configuration is not so smart and we cannot define any rule like "use this mapping or, if it's not defined, use this instead" 馃槩 The only way to differentiate mappings is to separate entities into subdirectories and configure mapping for them.

As a first proposal, I wanted to move all Sylius entities to src/Entity/Sylius and create another src/Entity/Main directory with different configurations. I found it kinda weird, so I propose a separate configuration for each pack of entities and another one for a src/Entity/Main (name to be refactored), as a directory for custom entities.

I don't know is it the best solution. More, I don't even know if maybe it's my imagined problem 馃槃 But I would love to see an opinion of others @Sylius/core-team members and, of course, from our beloved community 馃帀

Live long and prosper 馃枛 鈽笍

@Zales0123 Zales0123 added the RFC label Mar 19, 2019

@Zales0123 Zales0123 requested a review from Sylius/core-team as a code owner Mar 19, 2019

@Zales0123 Zales0123 force-pushed the Zales0123:better-mapping-configuration branch from 0b0231f to c1dd292 Mar 19, 2019

type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
type: yml

This comment has been minimized.

Copy link
@lchrusciel

lchrusciel Mar 19, 2019

Member

Can we stay with one type of mapping among all files by default? I prefer to use XML, but even more, I prefer to remain consistent.

This comment has been minimized.

Copy link
@lchrusciel

lchrusciel Mar 19, 2019

Member

Also, maybe we should migrate to another configuration form and recommend it to all projects?

This comment has been minimized.

Copy link
@Zales0123

Zales0123 Mar 25, 2019

Author Member

The thing is, we need to keep annotation mapping for Sylius classes as they can be extended in Sylius plugins and it can be properly done only by traits with annotation mapping... But I agree with keeping one type of mapping by default 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.