Example #1
0
 /**
  * Initialize the driver.
  *
  * Validate configuration and perform all resource-intensive tasks needed to
  * make the driver active.
  *
  * @throws ILSException
  * @return void
  */
 public function init()
 {
     // Validate config
     $required = array('host', 'bib', 'useradm', 'admlib', 'dlfport', 'available_statuses');
     foreach ($required as $current) {
         if (!isset($this->config['Catalog'][$current])) {
             throw new ILSException("Missing Catalog/{$current} config setting.");
         }
     }
     if (!isset($this->config['sublibadm'])) {
         throw new ILSException('Missing sublibadm config setting.');
     }
     $lang = $this->translator->getTranslator()->getLocale();
     $this->alephWebService->init($this->config['Catalog'], $lang);
     $this->bib = explode(',', $this->config['Catalog']['bib']);
     $this->useradm = $this->config['Catalog']['useradm'];
     $this->admlib = $this->config['Catalog']['admlib'];
     $this->sublibadm = $this->config['sublibadm'];
     if (isset($this->config['duedates'])) {
         $this->duedates = $this->config['duedates'];
     }
     $this->available_statuses = explode(',', $this->config['Catalog']['available_statuses']);
     $this->quick_availability = isset($this->config['Catalog']['quick_availability']) ? $this->config['Catalog']['quick_availability'] : false;
     if (isset($this->config['util']['tab40']) && isset($this->config['util']['tab15']) && isset($this->config['util']['tab_sub_library'])) {
         if (isset($this->config['Cache']['type']) && null !== $this->cacheManager) {
             $cache = $this->cacheManager->getCache($this->config['Cache']['type']);
             $this->alephTranslator = $cache->getItem('alephTranslator');
         }
         if ($this->alephTranslator == false) {
             $this->alephTranslator = new AlephFileTranslator($this->config);
             if (isset($cache)) {
                 $cache->setItem('alephTranslator', $this->alephTranslator);
             }
         }
     } else {
         $this->alephTranslator = new AlephFixedTranslator();
     }
     if (isset($this->config['Catalog']['preferred_pick_up_locations'])) {
         $this->preferredPickUpLocations = explode(',', $this->config['Catalog']['preferred_pick_up_locations']);
     }
     if (isset($this->config['Catalog']['default_patron'])) {
         $this->defaultPatronId = $this->config['Catalog']['default_patron'];
     }
     $idResolverType = 'fixed';
     if (isset($this->config['IdResolver']['type'])) {
         $idResolverType = $this->config['IdResolver']['type'];
     }
     if ($idResolverType == 'fixed') {
         $this->idResolver = new FixedIdResolver();
     } else {
         if ($idResolverType == 'solr') {
             $this->idResolver = new SolrIdResolver($this->searchService, $this->config);
         } else {
             if ($idResolverType == 'xserver') {
                 $this->idResolver = new XServerIdResolver($this->alephWebService, $this->config);
             } else {
                 throw new ILSException('Unsupported Catalog[IdResolver][type]:' . $idResolverType . ', valid values are fixed, solr and xserver.');
             }
         }
     }
     if (isset($this->config['ILL']['hidden_statuses'])) {
         $this->IllHiddenStatuses = explode(',', $this->config['ILL']['hidden_statuses']);
     }
     if (isset($this->config['ILL']['default_ill_unit'])) {
         $this->defaultIllUnit = $this->config['ILL']['default_ill_unit'];
     }
     if (isset($this->config['ILL']['default_pickup_location'])) {
         $this->defaultIllPickupPlocation = $this->config['ILL']['default_pickup_location'];
     }
     if (isset($this->config['holdings']['default_required_date'])) {
         $this->defaultRequiredDate = $this->config['holdings']['default_required_date'];
     } else {
         $this->defaultRequiredDate = "0:1:0";
     }
 }