dependency injection - Laravel Repositories inside other repositories -


So I have recently started using repository patterns in my work projects. I will continue to follow the same question that I can not answer:

Is it OK to inject any other repository into an existing repository? What are the negative effects of doing this?

For example :

  class crawl repository tool crawl rhesosity interface {public function __ composition (archive repository $ collection) {$ This- & gt; Collection = $ archive; } ... ... public events with getCrawlList () {// $ $ stuff - crawl $ // with luggage-> archive}}   

Archive There are some methods within the CrawlsRepository to use the model, which means that to maintain this pattern, ArchiveRepository is required to be used

Thank you for any direction you can provide! :)

Technically it's okay to do this really it's really good because you can not have dependency injection You are using, so you are not bound to just one implementation.

Conceptually, the repository represents the wrapper around the data source access. So I think it is ok to use any other repository to get further information.

On the other hand, when you say: There are some methods inside the CrawlsRepository, which is to use only archive mode then there is nothing inside the crawleripository from ArchiveRepository Are related.

There are cases of usage here, when you want to return some things related to your crawl consolidator, but you want to restore the archives that are linked to your data in some way. In this situation, before returning to the crawl repository, call ArchiveRepository to gather the necessary archives.

But again, if one method requires only ArchiveRepository, then it seems that you are doing it wrong.

I hope my explanation is quite clear because it is a very abstract and subjective subject.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -