Ejemplo n.º 1
0
 /**
  * Construct the authentication manager.
  *
  * @param ServiceManager $sm Service manager.
  *
  * @return Manager
  */
 public static function getManager(ServiceManager $sm)
 {
     // Set up configuration:
     $config = $sm->get('VuFind\\Config')->get('config');
     try {
         // Check if the catalog wants to hide the login link, and override
         // the configuration if necessary.
         $catalog = $sm->get('VuFind\\ILSConnection');
         if ($catalog->loginIsHidden()) {
             $config = new \Zend\Config\Config($config->toArray(), true);
             $config->Authentication->hideLogin = true;
             $config->setReadOnly();
         }
     } catch (\Exception $e) {
         // Ignore exceptions; if the catalog is broken, throwing an exception
         // here may interfere with UI rendering. If we ignore it now, it will
         // still get handled appropriately later in processing.
         error_log($e->getMessage());
     }
     // Load remaining dependencies:
     $userTable = $sm->get('VuFind\\DbTablePluginManager')->get('user');
     $sessionManager = $sm->get('VuFind\\SessionManager');
     $pm = $sm->get('VuFind\\AuthPluginManager');
     $cookies = $sm->get('VuFind\\CookieManager');
     // Build the object and make sure account credentials haven't expired:
     $manager = new Manager($config, $userTable, $sessionManager, $pm, $cookies);
     $manager->checkForExpiredCredentials();
     return $manager;
 }