示例#1
0
 /**
  * Make an OAI-PMH request.  Die if there is an error; return a SimpleXML object
  * on success.
  *
  * @param string $verb   OAI-PMH verb to execute.
  * @param array  $params GET parameters for ListRecords method.
  *
  * @return object        SimpleXML-formatted response.
  */
 protected function sendRequest($verb, $params = [])
 {
     $result = $this->communicator->request($verb, $params);
     // Detect errors and die if one is found:
     if ($result->error) {
         $attribs = $result->error->attributes();
         throw new \Exception("OAI-PMH error -- code: {$attribs['code']}, " . "value: {$result->error}");
     }
     return $result;
 }
 /**
  * Get the communicator.
  *
  * @param Client                     $client    HTTP client
  * @param array                      $settings  Additional settings
  * @param ResponseProcessorInterface $processor Response processor
  * @param string                     $target    Target being configured (used for
  * error messages)
  *
  * @return Communicator
  */
 protected function getCommunicator(Client $client, array $settings, ResponseProcessorInterface $processor, $target)
 {
     if (empty($settings['url'])) {
         throw new \Exception("Missing base URL for {$target}.");
     }
     $comm = new Communicator($settings['url'], $client, $processor);
     // We only want the communicator to output messages if we are in verbose
     // mode; communicator messages are considered verbose output.
     if (isset($settings['verbose']) && $settings['verbose'] && ($writer = $this->getConsoleWriter($settings))) {
         $comm->setOutputWriter($writer);
     }
     return $comm;
 }
示例#3
0
 /**
  * Make an OAI-PMH request.  Die if there is an error; return a SimpleXML object
  * on success.
  *
  * @param string $verb   OAI-PMH verb to execute.
  * @param array  $params GET parameters for ListRecords method.
  *
  * @return object        SimpleXML-formatted response.
  */
 protected function sendRequest($verb, $params = [])
 {
     $response = $this->communicator->request($verb, $params);
     $this->checkResponseForErrors($response);
     return $response;
 }