Beispiel #1
0
 /**
  * @param EveApiReadWriteInterface $data
  * @param EveApiRetrieverInterface $retrievers
  * @param EveApiPreserverInterface $preservers
  * @param int                      $interval
  *
  * @throws LogicException
  */
 public function autoMagic(EveApiReadWriteInterface $data, EveApiRetrieverInterface $retrievers, EveApiPreserverInterface $preservers, $interval)
 {
     $this->getLogger()->debug(sprintf('Starting autoMagic for %1$s/%2$s', $this->getSectionName(), $this->getApiName()));
     if ('Char' === $this->getSectionName()) {
         $active = $this->getActiveCharacters();
         $ownerID = 'characterID';
     } else {
         $active = $this->getActiveCorporations();
         $ownerID = 'corporationID';
     }
     if (0 === count($active)) {
         $mess = sprintf('No active registered keys found for %1$s/%2$s', $this->getSectionName(), $this->getApiName());
         $this->getLogger()->info($mess);
         return;
     }
     foreach ($active as $activeKey) {
         if ($this->cacheNotExpired($this->getApiName(), $this->getSectionName(), $activeKey[$ownerID])) {
             continue;
         }
         foreach ($this->getKeyList() as $accountKey) {
             $data->setEveApiSectionName(strtolower($this->getSectionName()))->setEveApiName($this->getApiName());
             $activeKey['accountKey'] = $accountKey;
             $activeKey['rowCount'] = '2560';
             $data->setEveApiArguments($activeKey)->setEveApiXml();
             if (!$this->oneShot($data, $retrievers, $preservers, $interval)) {
                 // Special handling for optional faction warfare account.
                 if ('10000' === $accountKey) {
                     continue 1;
                 }
                 continue 2;
             }
         }
         $this->updateCachedUntil($data->getEveApiXml(), $interval, $activeKey[$ownerID]);
     }
 }
 /**
  * @param EveApiReadWriteInterface $data
  * @param EveApiRetrieverInterface $retrievers
  * @param EveApiPreserverInterface $preservers
  * @param int                      $interval
  *
  * @throws LogicException
  */
 public function autoMagic(EveApiReadWriteInterface $data, EveApiRetrieverInterface $retrievers, EveApiPreserverInterface $preservers, $interval)
 {
     $this->getLogger()->debug(sprintf('Starting autoMagic for %1$s/%2$s', $this->getSectionName(), $this->getApiName()));
     $active = $this->getActiveKeys();
     if (0 === count($active)) {
         $this->getLogger()->info('No active registered keys found');
         return;
     }
     foreach ($active as $key) {
         $data->setEveApiSectionName(strtolower($this->getSectionName()))->setEveApiName($this->getApiName());
         if ($this->cacheNotExpired($this->getApiName(), $this->getSectionName(), $key['keyID'])) {
             continue;
         }
         $data->setEveApiArguments($key)->setEveApiXml();
         $untilInterval = $interval;
         if (!$this->oneShot($data, $retrievers, $preservers, $untilInterval)) {
             continue;
         }
         $this->updateCachedUntil($data->getEveApiXml(), $untilInterval, $key['keyID']);
     }
 }
Beispiel #3
0
 /**
  * Special override to work around bug in Eve API server when including both KeyID and corporationID.
  *
  * @param EveApiReadWriteInterface $data
  *
  * @return bool
  * @throws \DomainException
  * @throws \InvalidArgumentException
  * @throws \LogicException
  */
 protected function processEvents(EveApiReadWriteInterface $data) : bool
 {
     $corpID = 0;
     $eventSuffixes = ['retrieve', 'transform', 'validate', 'preserve'];
     foreach ($eventSuffixes as $eventSuffix) {
         if ('retrieve' === $eventSuffix) {
             $corp = $data->getEveApiArguments();
             $corpID = $corp['corporationID'];
             // Can NOT include corporationID or will only get public info.
             if (array_key_exists('keyID', $corp)) {
                 unset($corp['corporationID']);
                 $data->setEveApiArguments($corp);
             }
         }
         if (false === $this->emitEvents($data, $eventSuffix)) {
             return false;
         }
         if ('retrieve' === $eventSuffix) {
             $data->addEveApiArgument('corporationID', $corpID);
         }
         if (false === $data->getEveApiXml()) {
             if ($data->hasEveApiArgument('accountKey') && '10000' === $data->getEveApiArgument('accountKey') && 'corp' === strtolower($data->getEveApiSectionName())) {
                 $mess = 'No faction warfare account data in';
                 $this->getYem()->triggerLogEvent('Yapeal.Log.log', Logger::INFO, $this->createEveApiMessage($mess, $data));
                 return false;
             }
             $this->getYem()->triggerLogEvent('Yapeal.Log.log', Logger::INFO, $this->getEmptyXmlDataMessage($data, $eventSuffix));
             return false;
         }
     }
     return true;
 }