Is there a simple way to inject a dependency into every repository instance in Doctrine2 ?
I have tried listening to the loadClassMetadata event and usi
Since Symfony 3.3+ and 2017 you can make use of services.
Instead of other proposed solutions here that lead to:
You can do it...
repository = $entityManager->getRepository(Post::class);
$this->yourOwnDependency = $yourOwnDependency
}
}
You can read more detailed tutorial with clear code examples in How to use Repository with Doctrine as Service in Symfony post.