/** * Main method to process current row returned by getNextRow() method. * You may throw an exception if something goes wrong. It will be logged but won't break the import process * @param array $row Depending on your data format, can be DOMNode, SimpleXMLIterator, SimpleXMLElement, CSV row... * @throws Exception * @return void */ public function process( $row ) { $rootImport = $this->importINI->variable( 'XMLImportSettings', 'RootImport' ); $publisherInfos = $this->fileHandler->getPublisherInfosFromFolderName( $row['publisher'] ); if ( empty( $publisherInfos['default_language'] ) ) { $publisherInfos['default_language'] = 'eng-GB'; } $filePath = eZSys::rootDir() . "/$rootImport/{$this->fileHandler->rootImportFolder}/{$publisherInfos['path']}/{$row['file']}"; XMLImportMonitor::initFile( $row['file'], $publisherInfos['path'], $publisherInfos['id'], md5_file($filePath) ); try { if ( empty( $row['file'] ) || empty( $publisherInfos['path'] ) ) return; try { $xmlOptions = new SQLIXMLOptions( array( 'xml_path' => $filePath, 'xml_parser' => 'dom' ) ); $sqliXmlParser = new SQLIXMLParser( $xmlOptions ); $this->xmlParser = $sqliXmlParser->parse(); } catch ( SQLIXMLException $e ) { $this->triggerException( $row['file'], $publisherInfos['path'], $e, 4 ); } $xslProcess = XMLImportMapping::getByFieldName('xsl_process', $publisherInfos['path']); if ( $xslProcess !== false ) { if ( !isset($this->xmlTransformers[$publisherInfos['path']]) ) { try { $xslFolder = $this->importINI->variable('XMLImportSettings', 'XSLTFolder'); $xmslOptions = new SQLIXMLOptions( array( 'xml_path' => eZSys::rootDir() . '/extension/' . $xslFolder . '/' . $xslProcess, 'xml_parser' => 'dom' ) ); $sqliXmlTransformer = new SQLIXMLParser( $xmslOptions ); $path = $publisherInfos['path']; $this->xmlTransformers[$path] = $sqliXmlTransformer->parse(); } catch ( SQLIXMLException $e ) { $this->triggerException( $row['file'], $publisherInfos['path'], $e, 4 ); } } // Configure the transformer $proc = new XSLTProcessor; $proc->importStyleSheet($this->xmlTransformers[$publisherInfos['path']]); $this->xmlParser = $proc->transformToDoc($this->xmlParser); } try { $xmlFieldBuilder = new XMLFieldBuilder( $this->xmlParser, $this->importINI ); } catch ( RootNodeException $e ) { $this->triggerException( $row['file'], $publisherInfos['path'], $e, 4 ); } try { $xmlFieldMixer = new XMLFieldMixer( $xmlFieldBuilder, $this->xmlParser, $this->importINI, $publisherInfos, $this->rootImportFolder ); $fieldArray = $xmlFieldMixer->process(); } catch ( MandatoryException $e ) { $this->triggerException( $row['file'], $publisherInfos['path'], $e, 3 ); } try { XMLImportDataHandler::updateMdd( $fieldArray ); } catch ( XMLImportDBException $e ) { XMLImportDB::rollbackQuery(); $e = new Exception( $e->getMessage() . "\n" . 'SQL action failed - Transaction will be rollbacked - Error Message : ' . XMLImportDB::getErrorMessage() ); $this->triggerException( $row['file'], $publisherInfos['path'], $e, 5 ); } //Archive XML and blobed files $this->fileHandler->archiveFiles( $publisherInfos['path'], $row['file'], $xmlFieldMixer->blobedFiles ); } catch ( Exception $e ) { XMLImportMonitor::commitFile(); throw $e; } $this->fileHandler->dataSourcesCompleted++; XMLImportMonitor::commitFile(); }