28

From 2.1 Magento has introduced Magento/Framework/Model/EntityManager

I may be wrong here but from my understanding it is to replace Magento/Framework/Model/AbstractModel which was implementing the feature via inheritance and solve this via composition (FYI : https://en.m.wikipedia.org/wiki/Composition_over_inheritance )

You can get an example here in the core files: https://github.com/magento/magento2/blob/59671558ecdab652b40db2d1a7c63d5b1dea0a92/app/code/Magento/Cms/Model/ResourceModel/Block.php

Basically all the CRUD operations are explicitly declared in the class and deferred to the EntityManager class. Before 2.1, the parent method was called via inheritance.

So my questions are:

  • what are the benefits of the EntityManager over the pre 2.1 inheritance system?
  • is simply declaring the CRUD methods (like the example above) enough to start implementing it in a custom CRUD module or is there more?
1
  • 1
    Not an answer - but I would hazard one of the benefits of using an EntityManager would be the ability for a possible injection of a Repository type system - where loading might happen in-memory rather than hitting the DB if the entity had already been pulled into memory, etc.
    – Navarr
    Commented Jul 25, 2016 at 17:04

1 Answer 1

18

Currently, we do not recommend to use EntityManager for your entities as it's an unfinished feature and we plan to make configuration more declarative.

Ideas of EntityManager are:

  • allow persist Data Entity by the interface (no need to extends from abstract classes)
  • make persistent explicit extensible
  • modularity
7
  • Thanks for that could you add to your answer the reason why you do not recommend using it ? (Unfinished feature, buggy, other?) Commented Jul 25, 2016 at 18:37
  • 1
    Yes, unfinished futures, we plan to make configuration more declarative
    – KAndy
    Commented Jul 26, 2016 at 7:11
  • 6
    Moar XMLs, MOAR! :)
    – nevvermind
    Commented Jul 26, 2016 at 17:35
  • Could we know what is the expected date they will finish this unfinished futures? Commented Aug 12, 2016 at 9:04
  • 3
    Because Magento backlog directly affected by community and partners feedback any task can be prioritized and deprioritized and no one know when concrete task will be finished, before it's done and published.
    – KAndy
    Commented Aug 12, 2016 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.