]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/front/controller/admin/ManageTagController.php
Handle pagination through BookmarkService
[github/shaarli/Shaarli.git] / application / front / controller / admin / ManageTagController.php
index 22fb461c1411173c8cb89df4a7de2006d6ba8b4f..1333cce72ef104a8c093aec164da71486b7e95f4 100644 (file)
@@ -32,7 +32,7 @@ class ManageTagController extends ShaarliAdminController
         $this->assignView('tags_separator', $separator);
         $this->assignView(
             'pagetitle',
-            t('Manage tags') .' - '. $this->container->conf->get('general.title', 'Shaarli')
+            t('Manage tags') . ' - ' . $this->container->conf->get('general.title', 'Shaarli')
         );
 
         return $response->write($this->render(TemplatePage::CHANGE_TAG));
@@ -57,9 +57,12 @@ class ManageTagController extends ShaarliAdminController
         }
 
         // TODO: move this to bookmark service
-        $count = 0;
-        $bookmarks = $this->container->bookmarkService->search(['searchtags' => $fromTag], BookmarkFilter::$ALL, true);
-        foreach ($bookmarks as $bookmark) {
+        $searchResult = $this->container->bookmarkService->search(
+            ['searchtags' => $fromTag],
+            BookmarkFilter::$ALL,
+            true
+        );
+        foreach ($searchResult->getBookmarks() as $bookmark) {
             if (false === $isDelete) {
                 $bookmark->renameTag($fromTag, $toTag);
             } else {
@@ -68,11 +71,11 @@ class ManageTagController extends ShaarliAdminController
 
             $this->container->bookmarkService->set($bookmark, false);
             $this->container->history->updateLink($bookmark);
-            $count++;
         }
 
         $this->container->bookmarkService->save();
 
+        $count = $searchResult->getResultCount();
         if (true === $isDelete) {
             $alert = sprintf(
                 t('The tag was removed from %d bookmark.', 'The tag was removed from %d bookmarks.', $count),
@@ -87,7 +90,7 @@ class ManageTagController extends ShaarliAdminController
 
         $this->saveSuccessMessage($alert);
 
-        $redirect = true === $isDelete ? '/admin/tags' : '/?searchtags='. urlencode($toTag);
+        $redirect = true === $isDelete ? '/admin/tags' : '/?searchtags=' . urlencode($toTag);
 
         return $this->redirect($response, $redirect);
     }