@@ -112,30 +112,35 @@ public function search(IUser $user, ISearchQuery $query): SearchResult {
112112 // prepare files results
113113 return SearchResult::paginated (
114114 $ this ->l10n ->t ('Tags ' ),
115- array_map (function (Node $ result ) use ($ userFolder , $ matchedTags , $ query ) {
116- // Generate thumbnail url
117- $ thumbnailUrl = $ this ->urlGenerator ->linkToRouteAbsolute ('core.Preview.getPreviewByFileId ' , ['x ' => 32 , 'y ' => 32 , 'fileId ' => $ result ->getId ()]);
118- $ path = $ userFolder ->getRelativePath ($ result ->getPath ());
119-
120- // Use shortened link to centralize the various
121- // files/folder url redirection in files.View.showFile
122- $ link = $ this ->urlGenerator ->linkToRoute (
123- 'files.View.showFile ' ,
124- ['fileid ' => $ result ->getId ()]
125- );
126-
127- $ searchResultEntry = new SearchResultEntry (
128- $ thumbnailUrl ,
129- $ result ->getName (),
130- $ this ->formatSubline ($ query , $ matchedTags [$ result ->getId ()]),
131- $ this ->urlGenerator ->getAbsoluteURL ($ link ),
132- $ result ->getMimetype () === FileInfo::MIMETYPE_FOLDER ? 'icon-folder ' : $ this ->mimeTypeDetector ->mimeTypeIcon ($ result ->getMimetype ())
133- );
134- $ searchResultEntry ->addAttribute ('fileId ' , (string )$ result ->getId ());
135- $ searchResultEntry ->addAttribute ('path ' , $ path );
136- return $ searchResultEntry ;
137- }, $ searchResults )
138- + $ tagResults ,
115+ [
116+ ...$ tagResults ,
117+ ...array_map (function (Node $ result ) use ($ userFolder , $ matchedTags , $ query ) {
118+ $ nodeId = $ result ->getId ();
119+ // Generate thumbnail url
120+ $ thumbnailUrl = $ this ->urlGenerator ->linkToRouteAbsolute ('core.Preview.getPreviewByFileId ' , ['x ' => 32 , 'y ' => 32 , 'fileId ' => $ nodeId ]);
121+ $ path = $ userFolder ->getRelativePath ($ result ->getPath ());
122+
123+ // Use shortened link to centralize the various
124+ // files/folder url redirection in files.View.showFile
125+ $ link = $ this ->urlGenerator ->linkToRoute (
126+ 'files.View.showFile ' ,
127+ ['fileid ' => $ nodeId ]
128+ );
129+
130+ $ searchResultEntry = new SearchResultEntry (
131+ $ thumbnailUrl ,
132+ $ result ->getName (),
133+ $ this ->formatSubline ($ query , $ matchedTags [$ nodeId ]),
134+ $ this ->urlGenerator ->getAbsoluteURL ($ link ),
135+ $ result ->getMimetype () === FileInfo::MIMETYPE_FOLDER
136+ ? 'icon-folder '
137+ : $ this ->mimeTypeDetector ->mimeTypeIcon ($ result ->getMimetype ())
138+ );
139+ $ searchResultEntry ->addAttribute ('fileId ' , (string )$ nodeId );
140+ $ searchResultEntry ->addAttribute ('path ' , $ path );
141+ return $ searchResultEntry ;
142+ }, $ searchResults )
143+ ],
139144 $ query ->getCursor () + $ query ->getLimit ()
140145 );
141146 }
0 commit comments