Skip to content


DDC-1175: Call chaining for entity manager #1778

doctrinebot opened this Issue · 4 comments

2 participants


Jira issue originally created by user dukeofgaming:

It would be nice to have the entity manager return $this in methods like persist and remove, so instead of having this:

$em = $this->get('doctrine')->getEntityManager();
$user = $em->find('AcmeHelloBundle:User', $id);

One could do this:

$em = $this->get('doctrine')->getEntityManager();
$user = $em->find('AcmeHelloBundle:User', $id);

It is a small improvement (and perhaps its not the best case to demonstrate it) but it makes using the entity manager more comfortable.


Comment created by @beberlei:

A fluent interface shouldnt be introduced just for convenience, it makes no sense here semenatically.


Comment created by dukeofgaming:

Well, I never spoke of any fluent interface, and method chaining —which can be easily confused with fluent interfaces or vice versa (read the Update at the bottom of— is often used for convenience, meaning readability and practicality.

So compare:




It is way less tedious and way more readable, and again, not a fluent interface, just method chaining to improve readability and ease of use.


Comment created by @beberlei:

No reason to reopen. We made this decision and its final


Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.