Skip to content

Fill in reference document about overriding each part of a bundle #735

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

Closed
weaverryan opened this issue Sep 30, 2011 · 16 comments
Closed

Fill in reference document about overriding each part of a bundle #735

weaverryan opened this issue Sep 30, 2011 · 16 comments
Labels
actionable Clear and specific issues ready for anyone to take them.
Milestone

Comments

@weaverryan
Copy link
Member

See the new entry introduced in sha: 8c97795

I think much of it will just be a reference (links to to other places), while some topics (because it's hard or impossible to override), should be discussed

@weaverryan
Copy link
Member Author

I've made some progress on this issue (as you can see, each section is short, and just points elsewhere), but there are several other areas that we can still cover. Many of those are sitting in the document and are waiting for your contribution :)

@userfriendly
Copy link

If I may I would like to ping you guys regarding the "Entities & Entity mapping" section in that document. Got lots and lots of questions about this - it doesn't seem to be covered in the documentation, and in the IRC channel I get confusing and contradicting suggestions about it.

@wouterj
Copy link
Member

wouterj commented Mar 22, 2013

Related PR: #2333

@xabbuh
Copy link
Member

xabbuh commented Apr 2, 2013

Doctrine added support to override attributes and so on in one of the latest version. Maybe we can use that?

@wouterj
Copy link
Member

wouterj commented Apr 2, 2013

Doctrine 2.3.x is used since Symfony 2.1, so we can use it.

@stof
Copy link
Member

stof commented Apr 2, 2013

AttributeOverride can be used to overwrite the mapping of an inherited field. So it makes it easier when a bundle provides a mapped superclass.
But overriding an entity of a bundle is still impossible.

@xabbuh
Copy link
Member

xabbuh commented Apr 3, 2013

That's right, but do you think that's a reason not to mention the already existing possibilities? Even if it's only one sentence like

It is not possible to override an entity of bundle. However, if a bundle provides a mapped superclass one can override attributes and associations.

and link it to the Doctrine documentation.

@wouterj
Copy link
Member

wouterj commented Apr 3, 2013

@xabbuh I'm 👍 for that, not finished documentation is worse.

@stof
Copy link
Member

stof commented Apr 3, 2013

@xabbuh sure it can be mentionned, but not as a way to overwrite entities

@DHorchler
Copy link

Hello everybody,
why not mention that Sympatch can be an alternative to override any part of a bundle, including entities, and is not even limited to PHP code?
https://github.com/DHorchler/SympatchBundle

@wouterj
Copy link
Member

wouterj commented Apr 6, 2013

I didn't look at the Sympatch bundle yet, but if it can be the solution for overriden bundle parts, I'm 👍 for it. I think including relevant and great bundles in the documentation is a usefull evolution.

@stof
Copy link
Member

stof commented Apr 6, 2013

This bundle is a hack IMO. It modifies the content of the vendor bundles, which does not play well with vendor updates

@DHorchler
Copy link

@stof hack sounds negative. I don't consider myself a hacker :-) .

Of course, my bundle's approach is much different from all other recommendations that deal with overriding foreign code.
Maybe it even lacks a certain elegance. But guess what? It works.

I gave a procedure for code base updates which consists in deactivate all patches, upgrade the code base and reactivate the patches, just 2 extra console commands (I believe that could be automated).

Can I guarantee that after vendor updates everything will work? I can't. But chances are good that it will.
Can anybody guarantee that when you override parts of foreign code and then that code is updated that still everything will work? I don't think so.

@trsteel88
Copy link
Contributor

If it is not possible to overwrite an entity. How is everyone using vendor bundles for projects?

Eg, a blog. Sometimes you may need to add additional fields to a post entity or you may want to add a blog category introduction field.

From what I understand, with the mapped super classes, it means you MUST create the sub classes in the app specific bundle. Also, this does not work for One-To-Many associations on the mapped super class so you couldn't setup a default structure for the blog with posts/categories?

Is it not possible to somehow intercept the mappings with an event and just point the mapped at a different class if it exists?

@merk
Copy link
Contributor

merk commented Jun 13, 2013

OneToMany Associations work fine with this method. Doctrine provides a ResolveTargetEntityListener that lets you define relationships against abstract classes or interfaces that can be overridden to point to a concrete implementation of an entity at runtime.

@drgomesp
Copy link

Does anyone have a solution for the overriding of mapped entities yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them.
Projects
None yet
Development

No branches or pull requests

9 participants