Esempio n. 1
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. 2
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;
 }