How to solve the problem of selection of repositories?

He built himself a small service architecture, di, repository, all the cases.
With the development of the project encountered one problem with the sample.

For example we have a method findByAll($limit, $condition), which returns multiple records.
For small queries, all cool:
$this->productRepository->findAll(100, ['status' => 1]),

But what if it's the goods and you need to fetch the list of such a plan:
- get products with all the correlations
- get the goods only data categories
- get the goods without correlations
- get products with pagination
- deliver the goods all but some

The result will be something like this:
$this->productRepository->findAll(100, [
 'relations' => ['categories', 'images', 'properties', 'values'],
 'sort' => ['date_create' => DESK],
 'notWhere' => [1, 2, 3]

The Lord tells us that instead of an array is to send the item to which the whole thing worked out. As I understand it, something similar to the criterion in yii1. However, in any case you have yourself in each method of the interface repository to add $condition and realize this.

Anyone have any views on the subject ?
July 9th 19 at 10:10
2 answers
July 9th 19 at 10:12
let me clarify that my advice was how to understand what the structure of these arrays must be the case a different implementation of the repository interface. To pass an object implementing the interface Criteria/QueryCondition etc.
July 9th 19 at 10:14
do every variant of his method in the repository.
funny. Now I know after whom I inherited a project where every view contain your html and body. - Justice commented on July 9th 19 at 10:17
after you try to write tests for a method in which 10 IFOV want to laugh. - nasir17 commented on July 9th 19 at 10:20
: that is correct, so you need to write 500 tests and 500 of methods in the repository with names like: findByIdWithCategoriesImagesPropertiesvaluespaginatebysortdesc() - Justice commented on July 9th 19 at 10:23

Find more questions by tags PHP