1 | <?php |
||
28 | class SearchFinder extends AbstractFinder implements FinderInterface, ModelsAwareInterface |
||
29 | { |
||
30 | |||
31 | use FinderHelpers, |
||
32 | UniqueModelsAwareTrait; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * |
||
37 | * @param object|object[] $models Model or array of model instances |
||
38 | * @param IndexManager $im |
||
39 | * @param Manganel $manganel |
||
40 | */ |
||
41 | 24 | public function __construct($models, $im = null, $manganel = null) |
|
|
|||
42 | { |
||
43 | 24 | if (is_array($models)) |
|
44 | { |
||
45 | 20 | $model = current($models); |
|
46 | } |
||
47 | else |
||
48 | { |
||
49 | // Ensure array and that model is set for further usage |
||
50 | 4 | $model = $models; |
|
51 | 4 | $models = [$models]; |
|
52 | } |
||
53 | 24 | foreach ($models as $modelIndex => $modelSignature) |
|
54 | { |
||
55 | 24 | if (is_string($modelSignature)) |
|
56 | { |
||
57 | $models[$modelIndex] = new $modelSignature; |
||
58 | } |
||
59 | } |
||
60 | 24 | if (is_string($model)) |
|
61 | { |
||
62 | $model = new $model; |
||
63 | } |
||
64 | 24 | if (null === $manganel) |
|
65 | { |
||
66 | 24 | $manganel = Manganel::create($model); |
|
67 | } |
||
68 | 24 | assert($model instanceof AnnotatedInterface); |
|
69 | |||
70 | 24 | $this->setModel($model); |
|
71 | 24 | $this->setModels($models); |
|
72 | 24 | $this->setScopeManager(new MultiScopeManager($model, $models)); |
|
73 | 24 | $this->setAdapter(new ElasticSearchAdapter($models)); |
|
74 | |||
75 | 24 | $this->setProfiler($manganel->getProfiler()); |
|
76 | 24 | $this->setFinderEvents(new Helpers\MultiFinderEvents()); |
|
77 | 24 | $this->withCursor(false); |
|
78 | 24 | } |
|
79 | |||
80 | /** |
||
81 | * Create search finder instance. |
||
82 | * |
||
83 | * @param AnnotatedInterface $model |
||
84 | * @param IndexManager $im |
||
85 | * @param Manganel $manganel |
||
86 | * @return FinderInterface |
||
87 | */ |
||
88 | public static function create(AnnotatedInterface $model, $im = null, Manganel $manganel = null) |
||
92 | |||
93 | 12 | protected function createModel($data) |
|
100 | |||
101 | } |
||
102 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.