From a55ce70ff9a468237ca337fa80d4fa49d87c63ce Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 12 Jul 2012 09:41:11 -0400
Subject: [PATCH] Moved Account Manager into Auth namespace; these things
 belong together.

---
 .../src/VuFind/{Account => Auth}/Manager.php   |  6 +++---
 module/VuFind/src/VuFind/Bootstrap.php         | 13 ++++++-------
 .../src/VuFind/Controller/AbstractBase.php     |  8 ++++----
 .../VuFind/Controller/MyResearchController.php | 18 +++++++++---------
 module/VuFind/src/VuFind/ILS/Logic/Holds.php   |  4 ++--
 .../VuFind/src/VuFind/ILS/Logic/TitleHolds.php |  4 ++--
 .../src/VuFind/RecordDriver/SolrDefault.php    |  2 +-
 .../src/VuFind/RecordDriver/SolrMarc.php       |  4 ++--
 .../src/VuFind/RecordDriver/WorldCat.php       |  2 +-
 .../src/VuFind/Search/Favorites/Params.php     |  8 ++++----
 .../src/VuFind/Search/Favorites/Results.php    |  2 +-
 11 files changed, 35 insertions(+), 36 deletions(-)
 rename module/VuFind/src/VuFind/{Account => Auth}/Manager.php (98%)

diff --git a/module/VuFind/src/VuFind/Account/Manager.php b/module/VuFind/src/VuFind/Auth/Manager.php
similarity index 98%
rename from module/VuFind/src/VuFind/Account/Manager.php
rename to module/VuFind/src/VuFind/Auth/Manager.php
index ee639492952..079375a8642 100644
--- a/module/VuFind/src/VuFind/Account/Manager.php
+++ b/module/VuFind/src/VuFind/Auth/Manager.php
@@ -25,8 +25,8 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://www.vufind.org  Main Page
  */
-namespace VuFind\Account;
-use VuFind\Auth\Factory as AuthFactory, VuFind\Config\Reader as ConfigReader,
+namespace VuFind\Auth;
+use VuFind\Config\Reader as ConfigReader,
     VuFind\Connection\Manager as ConnectionManager,
     VuFind\Exception\Auth as AuthException, VuFind\Exception\ILS as ILSException,
     VuFind\Registry, Zend\Session\Container as SessionContainer;
@@ -53,7 +53,7 @@ class Manager
     public function __construct()
     {
         $this->config = ConfigReader::getConfig();
-        $this->auth = AuthFactory::getAuth(
+        $this->auth = Factory::getAuth(
             $this->config->Authentication->method, $this->config
         );
         $this->session = new SessionContainer('Account');
diff --git a/module/VuFind/src/VuFind/Bootstrap.php b/module/VuFind/src/VuFind/Bootstrap.php
index b80a4766ac2..554f2316f94 100644
--- a/module/VuFind/src/VuFind/Bootstrap.php
+++ b/module/VuFind/src/VuFind/Bootstrap.php
@@ -26,8 +26,7 @@
  * @link     http://vufind.org   Main Site
  */
 namespace VuFind;
-use VuFind\Account\Manager as AccountManager,
-    VuFind\Cache\Manager as CacheManager,
+use VuFind\Auth\Manager as AuthManager, VuFind\Cache\Manager as CacheManager,
     VuFind\Config\Reader as ConfigReader,
     VuFind\Db\AdapterFactory as DbAdapterFactory,
     VuFind\Registry, VuFind\Theme\Initializer as ThemeInitializer,
@@ -125,17 +124,17 @@ class Bootstrap
      */
     protected function initAccount()
     {
-        $accountManager = new AccountManager();
+        $authManager = new AuthManager();
 
         // Register in service manager:
         $serviceManager = $this->event->getApplication()->getServiceManager();
-        $serviceManager->setService('AccountManager', $accountManager);
+        $serviceManager->setService('AuthManager', $authManager);
 
         // Register in view:
-        $callback = function($event) use ($accountManager) {
+        $callback = function($event) use ($authManager) {
             $serviceManager = $event->getApplication()->getServiceManager();
             $viewModel = $serviceManager->get('viewmanager')->getViewModel();
-            $viewModel->setVariable('account', $accountManager);
+            $viewModel->setVariable('account', $authManager);
         };
         $this->events->attach('dispatch', $callback);
     }
@@ -361,6 +360,6 @@ class Bootstrap
 
         // Check user credentials:
         $serviceManager = $this->event->getApplication()->getServiceManager();
-        $serviceManager->get('AccountManager')->checkForExpiredCredentials();
+        $serviceManager->get('AuthManager')->checkForExpiredCredentials();
     }
 }
\ No newline at end of file
diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php
index 534730cb997..d461b5fba32 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractBase.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php
@@ -75,9 +75,9 @@ class AbstractBase extends AbstractActionController
      *
      * @return \VuFind\Account\Manager
      */
-    protected function getAccount()
+    protected function getAuthManager()
     {
-        return $this->getServiceLocator()->get('AccountManager');
+        return $this->getServiceLocator()->get('AuthManager');
     }
 
     /**
@@ -87,7 +87,7 @@ class AbstractBase extends AbstractActionController
      */
     protected function getUser()
     {
-        return $this->getAccount()->isLoggedIn();
+        return $this->getAuthManager()->isLoggedIn();
     }
 
     /**
@@ -132,7 +132,7 @@ class AbstractBase extends AbstractActionController
     protected function catalogLogin()
     {
         // First make sure user is logged in to VuFind:
-        $account = $this->getAccount();
+        $account = $this->getAuthManager();
         if ($account->isLoggedIn() == false) {
             $this->forceLogin();
             return false;
diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php
index 10ec02ecd10..42b5f8a0692 100644
--- a/module/VuFind/src/VuFind/Controller/MyResearchController.php
+++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php
@@ -64,7 +64,7 @@ class MyResearchController extends AbstractBase
         // Process login request, if necessary:
         if ($this->params()->fromPost('processLogin')) {
             try {
-                $this->getAccount()->login($this->getRequest()->getPost());
+                $this->getAuthManager()->login($this->getRequest()->getPost());
             } catch (AuthException $e) {
                 $this->flashMessenger()->setNamespace('error')
                     ->addMessage($e->getMessage());
@@ -72,7 +72,7 @@ class MyResearchController extends AbstractBase
         }
 
         // Not logged in?  Force user to log in:
-        if (!$this->getAccount()->isLoggedIn()) {
+        if (!$this->getAuthManager()->isLoggedIn()) {
             return $this->forward()
                 ->dispatch('MyResearch', array('action' => 'Login'));
         }
@@ -103,7 +103,7 @@ class MyResearchController extends AbstractBase
     {
         // If authentication mechanism does not support account creation, send
         // the user away!
-        if (!$this->getAccount()->supportsCreation()) {
+        if (!$this->getAuthManager()->supportsCreation()) {
             return $this->forward()
                 ->dispatch('MyResearch', array('action' => 'Home'));
         }
@@ -121,7 +121,7 @@ class MyResearchController extends AbstractBase
         // Process request, if necessary:
         if (!is_null($this->params()->fromPost('submit', null))) {
             try {
-                $this->getAccount()->create($this->getRequest()->getPost());
+                $this->getAuthManager()->create($this->getRequest()->getPost());
                 return $this->forward()
                     ->dispatch('MyResearch', array('action' => 'Home'));
             } catch (AuthException $e) {
@@ -145,7 +145,7 @@ class MyResearchController extends AbstractBase
     {
         // If this authentication method doesn't use a VuFind-generated login
         // form, force it through:
-        if ($this->getAccount()->getSessionInitiator()) {
+        if ($this->getAuthManager()->getSessionInitiator()) {
             // Don't get stuck in an infinite loop -- if processLogin is already
             // set, it probably means Home action is forwarding back here to
             // report an error!
@@ -183,7 +183,7 @@ class MyResearchController extends AbstractBase
     {
         $serverHelper = new \Zend\View\Helper\ServerUrl();
         $url = $serverHelper->__invoke($this->url()->fromRoute('home'));
-        return $this->redirect()->toUrl($this->getAccount()->logout($url));
+        return $this->redirect()->toUrl($this->getAuthManager()->logout($url));
     }
 
     /**
@@ -194,7 +194,7 @@ class MyResearchController extends AbstractBase
     public function savesearchAction()
     {
         /* TODO:
-        $user = $this->getAccount()->isLoggedIn();
+        $user = $this->getAuthManager()->isLoggedIn();
         if ($user == false) {
             return $this->forceLogin();
         }
@@ -245,7 +245,7 @@ class MyResearchController extends AbstractBase
         $homeLibrary = $this->params()->fromPost('home_library', false);
         if (!empty($homeLibrary)) {
             $user->changeHomeLibrary($homeLibrary);
-            $this->getAccount()->updateSession($user);
+            $this->getAuthManager()->updateSession($user);
             $this->flashMessenger()->setNamespace('info')
                 ->addMessage('profile_update');
         }
@@ -506,7 +506,7 @@ class MyResearchController extends AbstractBase
 
         try {
             $params = new \VuFind\Search\Favorites\Params();
-            $params->setAccountManager($this->getAccount());
+            $params->setAuthManager($this->getAuthManager());
             $params->initFromRequest($this->getRequest()->getQuery());
             $results = new \VuFind\Search\Favorites\Results($params);
             $results->performAndProcessSearch();
diff --git a/module/VuFind/src/VuFind/ILS/Logic/Holds.php b/module/VuFind/src/VuFind/ILS/Logic/Holds.php
index c7450fb7342..9bc0f0076d4 100644
--- a/module/VuFind/src/VuFind/ILS/Logic/Holds.php
+++ b/module/VuFind/src/VuFind/ILS/Logic/Holds.php
@@ -52,8 +52,8 @@ class Holds
     /**
      * Constructor
      *
-     * @param \VuFind\Account\Manager $account Account manager object
-     * @param ILSConnection           $catalog A catalog connection
+     * @param \VuFind\Auth\Manager $account Auth manager object
+     * @param ILSConnection        $catalog A catalog connection
      */
     public function __construct($account, $catalog = false)
     {
diff --git a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php
index 3fbcaabe046..50608c6b4cd 100644
--- a/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php
+++ b/module/VuFind/src/VuFind/ILS/Logic/TitleHolds.php
@@ -52,8 +52,8 @@ class TitleHolds
     /**
      * Constructor
      *
-     * @param \VuFind\Account\Manager $account Account manager object
-     * @param ILSConnection           $catalog A catalog connection
+     * @param \VuFind\Auth\Manager $account Auth manager object
+     * @param ILSConnection        $catalog A catalog connection
      */
     public function __construct($account, $catalog = false)
     {
diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php
index 987563ad058..e1567dffd60 100644
--- a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php
+++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php
@@ -843,7 +843,7 @@ class SolrDefault extends AbstractBase
      * Get an array of information about record holdings, obtained in real-time
      * from the ILS.
      *
-     * @param \VuFind\Account\Manager $account Account manager object
+     * @param \VuFind\Auth\Manager $account Auth manager object
      *
      * @return array
      */
diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
index 37ddcbf24db..8feacc0be00 100644
--- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
+++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php
@@ -791,7 +791,7 @@ class SolrMarc extends SolrDefault
      * Get an array of information about record holdings, obtained in real-time
      * from the ILS.
      *
-     * @param \VuFind\Account\Manager $account Account manager object
+     * @param \VuFind\Auth\Manager $account Auth manager object
      *
      * @return array
      */
@@ -822,7 +822,7 @@ class SolrMarc extends SolrDefault
     /**
      * Get a link for placing a title level hold.
      *
-     * @param \VuFind\Account\Manager $account Account manager object
+     * @param \VuFind\Auth\Manager $account Auth manager object
      *
      * @return mixed A url if a hold is possible, boolean false if not
      * @access protected
diff --git a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php
index 8e23d96d030..f0e03966b68 100644
--- a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php
+++ b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php
@@ -69,7 +69,7 @@ class WorldCat extends SolrMarc
      * Get an array of information about record holdings, obtained in real-time
      * from the ILS.
      *
-     * @param \VuFind\Account\Manager $account Account manager object
+     * @param \VuFind\Auth\Manager $account Auth manager object
      *
      * @return array
      */
diff --git a/module/VuFind/src/VuFind/Search/Favorites/Params.php b/module/VuFind/src/VuFind/Search/Favorites/Params.php
index e4154c43d5f..d71072c99aa 100644
--- a/module/VuFind/src/VuFind/Search/Favorites/Params.php
+++ b/module/VuFind/src/VuFind/Search/Favorites/Params.php
@@ -88,9 +88,9 @@ class Params extends BaseParams
     /**
      * Get account manager.
      *
-     * @return \VuFind\Account\Manager
+     * @return \VuFind\Auth\Manager
      */
-    public function getAccountManager()
+    public function getAuthManager()
     {
         return $this->account;
     }
@@ -98,11 +98,11 @@ class Params extends BaseParams
     /**
      * Inject dependency: account manager.
      *
-     * @param \VuFind\Account\Manager $account Account manager object.
+     * @param \VuFind\Auth\Manager $account Auth manager object.
      *
      * @return void
      */
-    public function setAccountManager($account)
+    public function setAuthManager($account)
     {
         $this->account = $account;
     }
diff --git a/module/VuFind/src/VuFind/Search/Favorites/Results.php b/module/VuFind/src/VuFind/Search/Favorites/Results.php
index d523774fd4b..ca5f2aa315b 100644
--- a/module/VuFind/src/VuFind/Search/Favorites/Results.php
+++ b/module/VuFind/src/VuFind/Search/Favorites/Results.php
@@ -124,7 +124,7 @@ class Results extends BaseResults
     protected function performSearch()
     {
         $list = $this->getListObject();
-        $account = $this->getAccountManager();
+        $account = $this->getAuthManager();
         $this->user = $account ? $account->isLoggedIn() : false;
 
         // Make sure the user and/or list objects make it possible to view
-- 
GitLab