Exemplo n.º 1
0
 /**
  * @param EveApiReadInterface $data
  *
  * @throws YapealPreserverPathException
  * @throws \LogicException
  * @throws YapealPreserverFileException
  * @return self
  */
 public function preserveEveApi(EveApiReadInterface $data)
 {
     try {
         $cachePath = $this->getSectionCachePath($data->getEveApiSectionName());
         $this->checkUsableCachePath($cachePath);
         $hash = $data->getHash();
         // Insures retriever never see partly written file by using temp file.
         $cacheTemp = $cachePath . $data->getEveApiName() . $hash . '.tmp';
         $this->prepareConnection($cacheTemp)->writeXmlData($data->getEveApiXml(), $cacheTemp)->__destruct();
     } catch (YapealPreserverException $exc) {
         $mess = 'Could NOT get XML data';
         $this->getLogger()->info($mess, ['exception' => $exc]);
         return $this;
     }
     $cacheFile = $cachePath . $data->getEveApiName() . $hash . '.xml';
     rename($cacheTemp, $cacheFile);
     return $this;
 }
 /**
  * @param EveApiReadInterface $data
  *
  * @return \Guzzle\Http\Message\EntityEnclosingRequestInterface
  * @throws \LogicException
  */
 protected function prepareConnection(EveApiReadInterface $data)
 {
     $uri = ['/{EveApiSectionName}/{EveApiName}.xml.aspx', ['EveApiSectionName' => $data->getEveApiSectionName(), 'EveApiName' => $data->getEveApiName()]];
     $client = $this->getClient();
     return $client->post($uri, null, $data->getEveApiArguments());
 }
Exemplo n.º 3
0
 /**
  * @param EveApiReadInterface $data
  *
  * @throws LogicException
  * @return bool
  */
 protected function isInvalid(EveApiReadInterface $data)
 {
     $this->getLogger()->debug('Started XSD validating');
     $oldErrors = libxml_use_internal_errors(true);
     libxml_clear_errors();
     $dom = new DOMDocument();
     $dom->loadXML($data->getEveApiXml());
     $schema = sprintf($this->getCwd() . '%1$s/%2$s.xsd', ucfirst($data->getEveApiSectionName()), $data->getEveApiName());
     if ($dom->schemaValidate($schema)) {
         libxml_use_internal_errors($oldErrors);
         return false;
     }
     $logger = $this->getLogger();
     foreach (libxml_get_errors() as $error) {
         $logger->debug($error->message);
     }
     libxml_clear_errors();
     libxml_use_internal_errors($oldErrors);
     return true;
 }