예제 #1
0
 public function getRemoteTypes()
 {
     if (!$this->useCache || !isset($this->data['settings']['remote']['types'])) {
         list($localPath, $tmpDirCreated) = $this->getTemporalDirectory();
         static::downloadFile(self::REMOTE_TYPE_FILE, self::LOCAL_TYPE_FILE, false, $localPath);
         $csv = new CSVReader();
         $csv->AddEventCallback('AFTER_ASSOC_LINE_READ', array($this, 'provideEnFromRu'));
         $res = $csv->ReadBlock($localPath . self::LOCAL_TYPE_FILE);
         $result = array();
         foreach ($res as $line) {
             $result[$line['CODE']] = $line;
         }
         $this->data['settings']['remote']['types'] = $result;
         $csv->CloseFile();
         if ($tmpDirCreated) {
             $this->deleteDirectory($localPath);
         }
     }
     return $this->data['settings']['remote']['types'];
 }
예제 #2
0
 public function getRemoteTypes()
 {
     if (!$this->useCache || !isset($this->data['settings']['remote']['types'])) {
         $localPath = \CTempFile::GetDirectoryName(100);
         static::downloadFile(self::REMOTE_TYPE_FILE, self::LOCAL_TYPE_FILE, false, $localPath);
         $csv = new CSVReader();
         $csv->AddEventCallback('AFTER_ASSOC_LINE_READ', array($this, 'provideEnFromRu'));
         $res = $csv->ReadBlock($localPath . self::LOCAL_TYPE_FILE);
         $result = array();
         foreach ($res as $line) {
             $result[$line['CODE']] = $line;
         }
         $this->data['settings']['remote']['types'] = $result;
         if (\Bitrix\Main\IO\File::isFileExists($localPath . self::LOCAL_TYPE_FILE)) {
             try {
                 \Bitrix\Main\IO\File::deleteFile($localPath . self::LOCAL_TYPE_FILE);
                 \Bitrix\Main\IO\Directory::deleteDirectory($localPath);
             } catch (\Exception $e) {
             }
         }
     }
     return $this->data['settings']['remote']['types'];
 }