コード例 #1
0
 /**
  * get all exported files and a list of acknowledgment files imported
  * loop through all the exported files and check if each exported files has an imported acknowledgment file
  * in the list of acknowledgment files, if the file is in the list of
  * acknowledgment file, then simply move the exported to export_archive and the acknowledgment file to import_archive
  * otherwise the exported file has no acknowledgment therefore, check the created time of
  * exported file if is greater than the configurable elapse time simply move it back to
  * out-box to be exported again, however if the elapse time is less than the configurable
  * simply ignore the file
  * @return self
  */
 public function process()
 {
     $exportedList = $this->_listFilesByCfgKey(self::CFG_EXPORTED_FEED_DIR);
     if (!empty($exportedList)) {
         $importedList = $this->_getImportedAckFiles();
         foreach ($exportedList as $exported) {
             $ack = $this->_getAck($exported, $importedList);
             if (!is_null($ack)) {
                 $this->_mvTo($exported, self::CFG_EXPORT_ARCHIVE)->_mvTo($ack, self::CFG_IMPORT_ARCHIVE);
             } elseif ($this->_isTimedOut($exported)) {
                 // create the error directory since it's not automatically created
                 // when processing the feeds
                 $this->_coreHelper->createDir($this->_buildPath(self::CFG_ERROR_DIRECTORY));
                 $this->_mvTo($exported, self::CFG_ERROR_DIRECTORY);
                 $this->_logger->critical('{file_name} was not acknowledged by Product Hub', $this->_context->getMetaData(__CLASS__, ['file_name' => $exported]));
             }
         }
     }
     return $this;
 }