From cf1e0e11dea6f47a415a928c33eb8302199cb8c0 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 31 Oct 2017 12:55:23 -0400
Subject: [PATCH] Update flash messenger plugin.

---
 module/VuFind/config/module.config.php                |  8 ++++++--
 .../VuFind/src/VuFind/Controller/Plugin/NewItems.php  | 11 ++++++-----
 .../src/VuFind/View/Helper/Root/Flashmessages.php     |  2 +-
 .../src/VuFindTest/Controller/Plugin/NewItemsTest.php |  4 ++--
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 30cd51ba52b..962b601ba04 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -247,7 +247,6 @@ $config = [
     'controller_plugins' => [
         'factories' => [
             'favorites' => 'VuFind\Controller\Plugin\Factory::getFavorites',
-            'flashmessenger' => 'VuFind\Controller\Plugin\Factory::getFlashMessenger',
             'followup' => 'VuFind\Controller\Plugin\Factory::getFollowup',
             'holds' => 'VuFind\Controller\Plugin\Factory::getHolds',
             'newItems' => 'VuFind\Controller\Plugin\Factory::getNewItems',
@@ -257,11 +256,16 @@ $config = [
             'reserves' => 'VuFind\Controller\Plugin\Factory::getReserves',
             'resultScroller' => 'VuFind\Controller\Plugin\Factory::getResultScroller',
             'storageRetrievalRequests' => 'VuFind\Controller\Plugin\Factory::getStorageRetrievalRequests',
+            'Zend\Mvc\Plugin\FlashMessenger\FlashMessenger' =>
+                'VuFind\Controller\Plugin\Factory::getFlashMessenger',
         ],
         'invokables' => [
             'db-upgrade' => 'VuFind\Controller\Plugin\DbUpgrade',
             'renewals' => 'VuFind\Controller\Plugin\Renewals',
-        ]
+        ],
+        'aliases' => [
+            'flashMessenger' => 'Zend\Mvc\Plugin\FlashMessenger\FlashMessenger',
+        ],
     ],
     'service_manager' => [
         'allow_override' => true,
diff --git a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php
index 9eca3cbe6d7..dcdf9305c5e 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php
@@ -29,6 +29,7 @@ namespace VuFind\Controller\Plugin;
 
 use Zend\Config\Config;
 use Zend\Mvc\Controller\Plugin\AbstractPlugin;
+use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger;
 
 /**
  * Zend action helper to perform new items-related actions
@@ -61,11 +62,11 @@ class NewItems extends AbstractPlugin
     /**
      * Figure out which bib IDs to load from the ILS.
      *
-     * @param \VuFind\ILS\Connection                     $catalog ILS connection
-     * @param \VuFind\Search\Solr\Params                 $params  Solr parameters
-     * @param string                                     $range   Range setting
-     * @param string                                     $dept    Department setting
-     * @param \Zend\Mvc\Controller\Plugin\FlashMessenger $flash   Flash messenger
+     * @param \VuFind\ILS\Connection     $catalog ILS connection
+     * @param \VuFind\Search\Solr\Params $params  Solr parameters
+     * @param string                     $range   Range setting
+     * @param string                     $dept    Department setting
+     * @param FlashMessenger             $flash   Flash messenger
      *
      * @return array
      */
diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
index faef3a49cb7..b74e9bf50e4 100644
--- a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
+++ b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
@@ -27,7 +27,7 @@
  */
 namespace VuFind\View\Helper\Root;
 
-use Zend\Mvc\Controller\Plugin\FlashMessenger;
+use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger;
 use Zend\View\Helper\AbstractHelper;
 
 /**
diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php
index b806f5dc148..664756a5cdd 100644
--- a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php
+++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php
@@ -50,7 +50,7 @@ class NewItemsTest extends TestCase
      */
     public function testGetBibIDsFromCatalog()
     {
-        $flash = $this->createMock('Zend\Mvc\Controller\Plugin\FlashMessenger');
+        $flash = $this->createMock('Zend\Mvc\Plugin\FlashMessenger\FlashMessenger');
         $config = new Config(['result_pages' => 10]);
         $newItems = new NewItems($config);
         $bibs = $newItems->getBibIDsFromCatalog(
@@ -66,7 +66,7 @@ class NewItemsTest extends TestCase
      */
     public function testGetBibIDsFromCatalogWithIDLimit()
     {
-        $flash = $this->createMock('Zend\Mvc\Controller\Plugin\FlashMessenger');
+        $flash = $this->createMock('Zend\Mvc\Plugin\FlashMessenger\FlashMessenger');
         $flash->expects($this->once())->method('addMessage')
             ->with($this->equalTo('too_many_new_items'), $this->equalTo('info'));
         $config = new Config(['result_pages' => 10]);
-- 
GitLab