1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Api; |
||
4 | |||
5 | use Apps\Model\Front\Search\EntitySearchMain; |
||
6 | use Extend\Core\Arch\ApiController; |
||
7 | use Ffcms\Core\Exception\JsonException; |
||
8 | use Ffcms\Core\Helper\Type\Str; |
||
9 | |||
10 | /** |
||
11 | * Class Search. Make search with json response by standard model |
||
12 | * @package Apps\Controller\Api |
||
13 | */ |
||
14 | class Search extends ApiController |
||
15 | { |
||
16 | /** |
||
17 | * Print json response for search query based on standard model |
||
18 | * @return string |
||
19 | * @throws JsonException |
||
20 | */ |
||
21 | public function actionIndex(): ?string |
||
22 | { |
||
23 | $this->setJsonHeader(); |
||
24 | // get search query as string from request |
||
25 | $query = $this->request->query->get('query', null); |
||
26 | if (Str::likeEmpty($query) || Str::length($query) < 2) { |
||
27 | throw new JsonException('Short query'); |
||
28 | } |
||
29 | |||
30 | // initialize basic search model |
||
31 | $model = new EntitySearchMain($query, ['itemPerApp' => 3]); |
||
32 | $model->make(); |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | // build response by relevance as array |
||
35 | $response = $model->getRelevanceSortedResult(); |
||
36 | |||
37 | return json_encode([ |
||
38 | 'status' => 1, |
||
39 | 'count' => count($response), |
||
40 | 'data' => $response |
||
41 | ]); |
||
42 | } |
||
43 | } |
||
44 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.