Jira issue originally created by user @doctrinebot:
This issue is created automatically through a Github pull request on behalf of iltar:
Instead of using the repositoryClass, we use 'Repository as a Service'. This means that we inject our repository service instead of doing $em->getRepository('MyEntity'), this provides typehinting and autocomplete in IDEs. This introduces a minor inconvenience, we need to inject an EntityManagerInterface to provide persist/flush. We don't want the entire EntityManagerInterface capabilities just to store an object.
Using the ObjectPersisterInterface we can "hide" the EntityManagerInterface and only let the code know we have the persist and flush methods available. By default this is implemented on the EntityManager, but is also possible to be mocked or replaced by a custom implementation (rotating entity managers?).
public function **construct(ObjectPersisterInterface $op, MyEntityService $es)
$this->op = $op;
$this->es = $es;
public function doSomething($value)
$entity = $this->es->findByValue($value)->setValue('something');
public function doSomethingElse()
$entity = new MyEntity();
Comment created by @doctrinebot:
A related Github Pull-Request [GH-317] was closed:
Issue was closed with resolution "Won't Fix"