Git Product home page Git Product logo

Comments (7)

javiereguiluz avatar javiereguiluz commented on May 18, 2024

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.

Pierstoval avatar Pierstoval commented on May 18, 2024

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.

xabbuh avatar xabbuh commented on May 18, 2024

Doesn't the ManagerRegistry always return the right EntityManager instance no matter how many connections you have configured?

from easyadminbundle.

mmoreram avatar mmoreram commented on May 18, 2024

@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.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

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.

mmoreram avatar mmoreram commented on May 18, 2024

Take a look at this implementation.

https://github.com/elcodi/Core/blob/master/Services/ManagerProvider.php

:)

from easyadminbundle.

javiereguiluz avatar javiereguiluz commented on May 18, 2024

@braisdesousa thanks to @mmoreram and our friends from elcodi we've fixed this limitation in #99.

from easyadminbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.