I have a catch-all repository that has a constructor by which other repositories are accessed utilizing Laravel's dependency injection and type-hinting.
As so:
public function __construct(Example1 $example1, Example2 $example2, Example3 $example3)
{
$this->example1 = $example1;
$this->example2 = $example2;
$this->example3 = $example3;
}
My issue is that in one of these repositories (let's say Example3) comes back to this catch-all repository to do its own work, meaning in its constructor it injects the catch-all repository. I believe this is leading to a memory-leak because it leads to a recursive injection as each time it is injecting it is re-injecting the callee, and so on if that makes sense.
Is there any way to call the functionality I want from the catch-all repository without it re-injecting Example 3 back into its self? I realize there are other ways around this, but I am wondering if there is a way to modify the constructor when doing dependency injection in Laravel.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iT9sEU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire