Ejemplo 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;
 }
Ejemplo n.º 2
0
 /**
  * @param EveApiReadInterface $data
  *
  * @throws LogicException
  * @return bool
  */
 protected function gotApiLock(EveApiReadInterface $data)
 {
     $sql = $this->getCsq()->getApiLock($data->getHash());
     $this->getLogger()->info($sql);
     try {
         $stmt = $this->getPdo()->query($sql);
         return (bool) $stmt->fetchColumn();
     } catch (PDOException $exc) {
         $mess = sprintf('Could NOT get lock for %1$s/%2$s', $data->getEveApiSectionName(), $data->getEveApiName());
         $this->getLogger()->warning($mess, ['exception' => $exc]);
         return false;
     }
 }