@@ -35,38 +35,38 @@ |
||
| 35 | 35 | |
| 36 | 36 | class SearchController extends Controller { |
| 37 | 37 | |
| 38 | - /** @var ISearch */ |
|
| 39 | - private $searcher; |
|
| 40 | - /** @var ILogger */ |
|
| 41 | - private $logger; |
|
| 38 | + /** @var ISearch */ |
|
| 39 | + private $searcher; |
|
| 40 | + /** @var ILogger */ |
|
| 41 | + private $logger; |
|
| 42 | 42 | |
| 43 | - public function __construct( |
|
| 44 | - string $appName, |
|
| 45 | - IRequest $request, |
|
| 46 | - ISearch $search, |
|
| 47 | - ILogger $logger |
|
| 48 | - ) { |
|
| 49 | - parent::__construct($appName, $request); |
|
| 43 | + public function __construct( |
|
| 44 | + string $appName, |
|
| 45 | + IRequest $request, |
|
| 46 | + ISearch $search, |
|
| 47 | + ILogger $logger |
|
| 48 | + ) { |
|
| 49 | + parent::__construct($appName, $request); |
|
| 50 | 50 | |
| 51 | - $this->searcher = $search; |
|
| 52 | - $this->logger = $logger; |
|
| 53 | - } |
|
| 51 | + $this->searcher = $search; |
|
| 52 | + $this->logger = $logger; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @NoAdminRequired |
|
| 57 | - */ |
|
| 58 | - public function search(string $query, array $inApps = [], int $page = 1, int $size = 30): JSONResponse { |
|
| 59 | - $results = $this->searcher->searchPaged($query, $inApps, $page, $size); |
|
| 55 | + /** |
|
| 56 | + * @NoAdminRequired |
|
| 57 | + */ |
|
| 58 | + public function search(string $query, array $inApps = [], int $page = 1, int $size = 30): JSONResponse { |
|
| 59 | + $results = $this->searcher->searchPaged($query, $inApps, $page, $size); |
|
| 60 | 60 | |
| 61 | - $results = array_filter($results, function (Result $result) { |
|
| 62 | - if (json_encode($result, JSON_HEX_TAG) === false) { |
|
| 63 | - $this->logger->warning("Skipping search result due to invalid encoding: {type: " . $result->type . ", id: " . $result->id . "}"); |
|
| 64 | - return false; |
|
| 65 | - } else { |
|
| 66 | - return true; |
|
| 67 | - } |
|
| 68 | - }); |
|
| 61 | + $results = array_filter($results, function (Result $result) { |
|
| 62 | + if (json_encode($result, JSON_HEX_TAG) === false) { |
|
| 63 | + $this->logger->warning("Skipping search result due to invalid encoding: {type: " . $result->type . ", id: " . $result->id . "}"); |
|
| 64 | + return false; |
|
| 65 | + } else { |
|
| 66 | + return true; |
|
| 67 | + } |
|
| 68 | + }); |
|
| 69 | 69 | |
| 70 | - return new JSONResponse($results); |
|
| 71 | - } |
|
| 70 | + return new JSONResponse($results); |
|
| 71 | + } |
|
| 72 | 72 | } |