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)
- Ability to add html attributes to crud pages HOT 2
- crud only for blameables if not admin HOT 3
- Passing too large a date to a DateTimeFilter causes a warning
- Warning: Trying to access array offset on value of type null HOT 2
- [4.9.1] Action::linkToRoute does not handle reverse proxy context HOT 1
- Assets does not included for embedded crud form fields HOT 1
- Some bootstrap functionnalities don't work if we use stimulus HOT 3
- Use AdminUrlGeneratorInterface instead of AdminUrlGenerator directly HOT 1
- Allow fields containing null-safe property paths HOT 1
- AdminUrlGenerator always includes entityId, even when it should redirect to the Index page HOT 4
- setHtmlAttributes methods doesn't create multiple attributs HOT 1
- custom voter case self::NEW: HOT 1
- Collection::allowDelete should still allow deletion of unsaved items HOT 4
- ChoiceField select html choices in CollectionField
- Dynamic Form Fields
- crud edit header - border is not visible / css HOT 1
- CollectionField with json
- Allows ToggleSwitch to dispatch a subscribable event
- Search not working with POSTRGES HOT 7
- Toggle switch on/off not working HOT 2
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.