Esempio n. 1
0
 /**
  * Constructor
  *
  * @param ConfigInterface $configuration Configuration settings (optional)
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     // These objects are not meant to be shared -- every time we retrieve one,
     // we are building a brand new object.
     $this->setShareByDefault(false);
     parent::__construct($configuration);
 }
Esempio n. 2
0
 /**
  * Retrieve results for the providers specified.
  *
  * @param string $isbn ISBN to use for lookup
  *
  * @return array
  */
 public function loadByIsbn($isbn)
 {
     $results = [];
     if (!($isbnObj = $this->getIsbnObject($isbn))) {
         return $results;
     }
     // Fetch from provider
     $providers = explode(',', $this->providers);
     foreach ($providers as $provider) {
         $parts = explode(':', trim($provider));
         $provider = $parts[0];
         if (!empty($provider)) {
             $key = isset($parts[1]) ? $parts[1] : '';
             try {
                 $plugin = $this->loader->get($provider);
                 $results[$provider] = $plugin->loadByIsbn($key, $isbnObj);
                 // If the current provider had no valid data, store nothing:
                 if (empty($results[$provider])) {
                     unset($results[$provider]);
                 }
             } catch (\Exception $e) {
                 // Ignore exceptions:
                 error_log($e->getMessage());
                 unset($results[$provider]);
             }
         }
     }
     return $results;
 }
Esempio n. 3
0
 /**
  * Constructor
  *
  * @param ConfigInterface $configuration Configuration settings (optional)
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     // These plugins are not meant to be shared -- the same module may be used
     // multiple times with different configurations, so we need to build a new
     // copy each time the plugin is retrieved.
     $this->setShareByDefault(false);
     parent::__construct($configuration);
 }
Esempio n. 4
0
 /**
  * Retrieve a service from the manager by name
  *
  * Allows passing an array of options to use when creating the instance.
  * createFromInvokable() will use these and pass them to the instance
  * constructor if not null and a non-empty array.
  *
  * @param string $name                      Service name
  * @param array  $options                   Options array
  * @param bool   $usePeeringServiceManagers Use peering service managers switch
  *
  * @return object
  */
 public function get($name, $options = array(), $usePeeringServiceManagers = true)
 {
     // Obtain the object from the parent:
     $obj = parent::get($name, $options, $usePeeringServiceManagers);
     // Make sure it is properly initialized:
     $obj->initialize();
     return $obj;
 }
Esempio n. 5
0
 /**
  * Constructor
  *
  * Make sure table gateways are properly initialized.
  *
  * @param ConfigInterface $configuration Configuration settings (optional)
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     parent::__construct($configuration);
     $initializer = function ($instance, $manager) {
         $instance->setAdapter($manager->getServiceLocator()->get('VuFind\\DbAdapter'));
         $instance->initialize();
     };
     $this->addInitializer($initializer, false);
 }
Esempio n. 6
0
 /**
  * Constructor
  *
  * @param ConfigInterface $configuration Configuration settings (optional)
  */
 public function __construct(ConfigInterface $configuration = null)
 {
     // Record drivers are not meant to be shared -- every time we retrieve one,
     // we are building a brand new object.
     $this->setShareByDefault(false);
     parent::__construct($configuration);
     // Add an initializer for setting up hierarchies
     $initializer = function ($instance, $manager) {
         $hasHierarchyType = is_callable([$instance, 'getHierarchyType']);
         if ($hasHierarchyType && is_callable([$instance, 'setHierarchyDriverManager'])) {
             $sm = $manager->getServiceLocator();
             if ($sm && $sm->has('VuFind\\HierarchyDriverPluginManager')) {
                 $instance->setHierarchyDriverManager($sm->get('VuFind\\HierarchyDriverPluginManager'));
             }
         }
     };
     $this->addInitializer($initializer, false);
 }