-
Notifications
You must be signed in to change notification settings - Fork 58
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
Event "data_definitions.import.total" never gets dispatched #320
Conversation
By counting the traversable object before creating the IteratorIterator object, no exception will be thrown when looping over the dataset after counting the elements.
works for me, what does @dkarlovi think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small tweaks, otherwise good with me.
src/DataDefinitionsBundle/Provider/TraversableImportDataSet.php
Outdated
Show resolved
Hide resolved
src/DataDefinitionsBundle/Provider/TraversableImportDataSet.php
Outdated
Show resolved
Hide resolved
{ | ||
$this->iterator = new \IteratorIterator($iterator); | ||
$this->count = iterator_count($iterator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this lazy? Only count it if the count is requested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible to do a count on a iterator since you can only rewind ones. That's why im doing this in the constructor before the IteratorIterator object is created. The count is also always requested in the importer.
@dpfaffenbauer looked at it, posted a review. |
@dpfaffenbauer If we could merge this one as well. Would be awesome 😄 |
In Importer.php the event "data_definitions.import.total" never gets get dispatched when $data is an object of type \Wvision\Bundle\DataDefinitionsBundle\Provider\TraversableImportDataSet.
Fixed this by adding Countable interface and setting the count on object creation.