Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File has multiple messages #87

Closed
erleeman opened this issue Oct 17, 2018 · 6 comments
Closed

File has multiple messages #87

erleeman opened this issue Oct 17, 2018 · 6 comments

Comments

@erleeman
Copy link

$this->errors[] = 'File has multiple messages';

Will that be possible someday?
For now you have to seperate the messages within a file manually?

Thank you.

@sabas
Copy link
Collaborator

sabas commented Oct 17, 2018

In Analyser I split them correctly
https://github.com/php-edifact/edifact/blob/master/src/EDI/Interpreter.php#L133

How do you use Reader?

@erleeman
Copy link
Author

$parser = new Parser($file_content);
$reader = new Reader();
$reader->setParsedFile($this->parser->get());

$reader->readEdiDataValue(['NAD', ['1' => 'SE']], 2, 0);

But for more than 1 message the 'File has multiple messages' error is logged.

@sabas
Copy link
Collaborator

sabas commented Oct 17, 2018

Since Reader accepts an array, if you don't want to change the code you could call setParsedFile on each message.
Or, to change the code, the trick would be to fix the lines with $parsedfile. I see that there's a splitMultiMessage function which is similar to my splitMessage.
It could use a refactoring.... Reader, Analyser and Interpreter do similar things with different approaches.

@erleeman
Copy link
Author

OK. Like in #84
But now, i recognized that preValidate for setParsedFile with extracted groups will return false.

I did not noticed splitMultiMessage. I will have a look.

Thank you.

@erleeman
Copy link
Author

Thank you for pointing out splitMulitMessage.

Have a look for testSplitMultiMessage. That figures out how to use it.

public function testSplitMultiMessage()

@erleeman
Copy link
Author

Seperating the file and loop each message.

public function testSplitMultiMessage()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants