forked from wallabag/wallabag
Move to controller as a service
Mostly using autowiring to inject deps. The only tricky part was for import because all producer use the same class and have a different alias. So we must write them down in the service definition, autowiring doesn't work in that case. Usually: - if a controller has a constructor, it means injected services are at least re-used once in actions - otherwise, service are injected per action
This commit is contained in:
@ -58,7 +58,7 @@ class SearchRestController extends WallabagRestController
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function getSearchAction(Request $request)
|
||||
public function getSearchAction(Request $request, EntryRepository $entryRepository)
|
||||
{
|
||||
$this->validateAuthentication();
|
||||
|
||||
@ -66,12 +66,11 @@ class SearchRestController extends WallabagRestController
|
||||
$page = (int) $request->query->get('page', 1);
|
||||
$perPage = (int) $request->query->get('perPage', 30);
|
||||
|
||||
$qb = $this->get(EntryRepository::class)
|
||||
->getBuilderForSearchByUser(
|
||||
$this->getUser()->getId(),
|
||||
$term,
|
||||
null
|
||||
);
|
||||
$qb = $entryRepository->getBuilderForSearchByUser(
|
||||
$this->getUser()->getId(),
|
||||
$term,
|
||||
null
|
||||
);
|
||||
|
||||
$pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
|
||||
$pager = new Pagerfanta($pagerAdapter);
|
||||
|
||||
Reference in New Issue
Block a user