/** * @see Billrun_Plugin_Interface_IProcessor::processData */ public function processData($type, $fileHandle, \Billrun_Processor &$processor) { if ($type != $this->getName()) { return FALSE; } $bytes = null; $headerData = fread($fileHandle, self::HEADER_LENGTH); $header = $processor->getParser()->parseHeader($headerData); if (isset($header['data_length_in_block']) && !feof($fileHandle)) { $bytes = fread($fileHandle, $header['data_length_in_block'] - self::HEADER_LENGTH); } do { $row = $processor->buildDataRow($bytes); if ($row) { $processor->addDataRow($row); } $bytes = substr($bytes, $processor->getParser()->getLastParseLength()); } while (isset($bytes[self::TRAILER_LENGTH + 1])); $trailer = $processor->getParser()->parseTrailer($bytes); //align the readhead if (self::RECORD_ALIGNMENT - $header['data_length_in_block'] > 0) { fread($fileHandle, self::RECORD_ALIGNMENT - $header['data_length_in_block']); } //add trailer data $processorData =& $processor->getData(); $processorData['trailer'] = $this->updateBlockData($trailer, $header, $processorData['trailer']); return true; }
/** * @see Billrun_Plugin_Interface_IProcessor::processData */ public function processData($type, $fileHandle, \Billrun_Processor &$processor) { if ($type != $this->getName()) { return FALSE; } $bytes = null; $headerData = fread($fileHandle, self::HEADER_LENGTH); $header = $processor->getParser()->parseHeader($headerData); if (isset($header['data_length_in_block']) && !feof($fileHandle)) { $bytes = fread($fileHandle, $header['data_length_in_block'] - self::HEADER_LENGTH); } if (in_array($header['format_version'], $this->nsnConfig['block_config']['supported_versions'])) { do { $row = $processor->buildDataRow($bytes); if ($row) { $processor->addDataRow($row); } $bytes = substr($bytes, $processor->getParser()->getLastParseLength()); } while (isset($bytes[self::TRAILER_LENGTH + 1])); } else { Billrun_Factory::log()->log("Got NSN block with unsupported version : {$header['format_version']} , block header data : " . print_r($header, 1), Zend_log::CRIT); } $trailer = $processor->getParser()->parseTrailer($bytes); //align the readhead $alignment = self::RECORD_ALIGNMENT * max(1, $header['charging_block_size']); if ($alignment - $header['data_length_in_block'] > 0) { fread($fileHandle, $alignment - $header['data_length_in_block']); } //add trailer data $processorData =& $processor->getData(); $processorData['trailer'] = $this->updateBlockData($trailer, $header, $processorData['trailer']); return true; }