Comments (7)
Thanks for your proposal. I don't know how many people would need this, but it seems a reasonable request. My proposal is to add a new option called em
which sets the name of the EntityManager associated with the entity and it defaults to default
. Example:
# app/config/config.yml
easy_admin:
entities:
Customer:
class: AppBundle\Entity\Customer
em: 'legacy'
Products:
class: AppBundle\Entity\Products
em: 'default' # equivalent to not setting this option
If someone is reading this issue and is tempted to submit a pull request: thanks, but please don't submit a pull request. We need to carefully think if this is a common-enough feature and then decide how we implement it. Thanks for understanding it!
from easyadminbundle.
I may probably need in one of my future apps, because I'll have two different databases, and one with a feaking old-rubbish mapping system, so I'll be glad to handle this with an entity manager.
By the way, renaming em
to entity_manager
seems more verbose and explicit to me, even if I also tend to reduce these words to "em" in class attributes/vars. It's better readability for the docs too.
from easyadminbundle.
Doesn't the ManagerRegistry
always return the right EntityManager
instance no matter how many connections you have configured?
from easyadminbundle.
@javiereguiluz You don't have to define how your entities are mapped in your database. This is actually done in Doctrine.
The way to work with the correct manager is just not working with the default one. Every time you want to work with an ObjectManager, you should request it given the entity you want to work with (Using the ManagerRegistry as a factory). Even you want to work with two different but associated entities, you should request one manager per entity (You don't really know if these entities are really associated).
This is the way to give the maximum flexibility and compatibility with all projects.
from easyadminbundle.
Thank you all for your explanations. We may add this feature easily because the only place where we set the entity manager to use is this line of the AdminController (https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Controller/AdminController.php#L97):
$this->em = $this->getDoctrine()->getManager();
If we could detect the entity manager of the given entity, then we'll always use the right entity manager. I'll have a look at this issue and see if it's really so easy to solve it as it looks.
from easyadminbundle.
Take a look at this implementation.
https://github.com/elcodi/Core/blob/master/Services/ManagerProvider.php
:)
from easyadminbundle.
@braisdesousa thanks to @mmoreram and our friends from elcodi we've fixed this limitation in #99.
from easyadminbundle.
Related Issues (20)
- Inconsistent behaviour when no entityId is passed to detail page
- Stop using PATCH HOT 18
- Default field for boolean property doesn't load field-boolean.js HOT 4
- Add some join for default query for NEW, EDIT, and DETAIL pages HOT 2
- EasyAdmin Autocomplete clear behaviour
- [Doc] Add an example of custom CRUD action
- Not possible to link a symfony controller HOT 1
- Feature Request: add edit link to Entity grid row name
- Route definitions in read-only file systems
- PercentField ignores "numDecimals" option
- Filters of the previous page shouldn't be passed to the next pages
- Add options to customize `ArrayField` button labels
- Text fields Max Length option is ignored HOT 7
- It doesn't create related records
- Dashboard title tag not set using content_title block HOT 1
- TextEditorType does not render in custom FieldType HOT 1
- How to use same function for two Entity Event ? HOT 1
- CollectionField: Add item and remove buttons do not work in EasyAdmin 4 CRUD update HOT 1
- Batch actions menu hides - 3.3.0
- Add addDisplayOnPage in src/Field/FieldTrait.php HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyadminbundle.