コード例 #1
0
ファイル: Processor.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Transfer generated catalog to PB server
  * 
  * @param array $files Catalog files
  * @param boolean $isDifferential Differential export (default: false)
  *
  * @return boolean
  */
 public function submitCatalog($files, $isDifferential = false)
 {
     $result = false;
     if (is_array($files) && count($files) > 0) {
         ob_start();
         \XLite\Module\XC\PitneyBowes\Model\Shipping\Processor\PitneyBowes::logDebug($this->config->sftp_username);
         \XLite\Module\XC\PitneyBowes\Model\Shipping\Processor\PitneyBowes::logDebug(array_map(function ($info) {
             return $info->getRealPath();
         }, $files));
         $sftp = $this->loginToSFTP();
         if ($sftp) {
             $sftp->chdir('tmp');
             foreach ($files as $filename => $info) {
                 $sftp->put($filename, $info->getRealPath(), \phpseclib\Net\SFTP::SOURCE_LOCAL_FILE);
                 $sftp->rename($filename, '../inbound/' . $filename);
                 $export = new PitneyBowes\Model\PBExport();
                 $export->setFilename($filename);
                 $export->setDifferential($isDifferential);
                 \XLite\Core\Database::getRepo('XLite\\Module\\XC\\PitneyBowes\\Model\\PBExport')->insert($export);
                 \XLite\Logger::logCustom("PitneyBowes", 'Export was successfully submitted to PB SFTP (file: ' . $filename . ')', false);
             }
             $result = true;
         }
         $buffer = ob_get_contents();
         ob_end_clean();
         if ($buffer) {
             \XLite\Module\XC\PitneyBowes\Model\Shipping\Processor\PitneyBowes::logDebug($buffer);
         }
     }
     return $result;
 }