]> BookStack Code Mirror - bookstack/blobdiff - app/Search/SearchController.php
Tests: Updated comment test to account for new editor usage
[bookstack] / app / Search / SearchController.php
index 08f0826dd608f2872f75fa0d3b31f3988e945ecf..2fce6a3d53fb86e14e1b773f4126f0b1ba456fb2 100644 (file)
@@ -2,9 +2,8 @@
 
 namespace BookStack\Search;
 
-use BookStack\Entities\Models\Page;
 use BookStack\Entities\Queries\PageQueries;
-use BookStack\Entities\Queries\Popular;
+use BookStack\Entities\Queries\QueryPopular;
 use BookStack\Entities\Tools\SiblingFetcher;
 use BookStack\Http\Controller;
 use Illuminate\Http\Request;
@@ -68,7 +67,7 @@ class SearchController extends Controller
      * Search for a list of entities and return a partial HTML response of matching entities.
      * Returns the most popular entities if no search is provided.
      */
-    public function searchForSelector(Request $request)
+    public function searchForSelector(Request $request, QueryPopular $queryPopular)
     {
         $entityTypes = $request->filled('types') ? explode(',', $request->get('types')) : ['page', 'chapter', 'book'];
         $searchTerm = $request->get('term', false);
@@ -79,7 +78,7 @@ class SearchController extends Controller
             $searchTerm .= ' {type:' . implode('|', $entityTypes) . '}';
             $entities = $this->searchRunner->searchEntities(SearchOptions::fromString($searchTerm), 'all', 1, 20)['results'];
         } else {
-            $entities = (new Popular())->run(20, 0, $entityTypes);
+            $entities = $queryPopular->run(20, 0, $entityTypes);
         }
 
         return view('search.parts.entity-selector-list', ['entities' => $entities, 'permission' => $permission]);