Function to reindex all segments in a message #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new function to the Message class to re-index all of the segments in a message. When we're reading and building multiple messages, the index/sequence ids can be added in weird and unpredictable ways because of the static/global
$setId
variables.This solution lets you add any segments you need and then step through and re-index all of the segments so that each segment types starts with 1 and increases by 1 for each segment of that type.
I think a better solution might be to keep up with the segment ids in the Message class (as an instance variable, instead of static variables on each segment class) so that as you add segments they can be set/incremented if that option is set. And multiple messages wouldn't interfere with each other.