Is there any difference between these two statements:
$this->getDoctrine()->getEntityManager()->getRepository();
$this->getDoctrine()->getRepository();
Does the difference relate to any OOP concept I am missing out?
In general, no difference, since
$this->getDoctrine()->getRepository();
is just a helper for
$this->getDoctrine()->getEntityManager()->getRepository();
You can have several entity managers, and then there will be a slight difference in getting a repository from one:
$this->getDoctrine()->getRepository($entityName, $enityManagerName);
$this->getDoctrine()->getEntityManager($entityManagerName)->getRepository($entityName);
But again, no difference in the result you'll get.
All other things being equal, I'd go with the shortest one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With