public function beforeRunPost(SourceSetEvent $sourceSetEvent) { $anItemHasChanged = false; foreach ($this->collection as $item) { if ($item->hasChanged()) { $anItemHasChanged = true; $this->collection->init(); break; } } if ($anItemHasChanged) { foreach ($sourceSetEvent->allSources() as $source) { if ($source->data()->get('use') && in_array($this->dataProviderName, $source->data()->get('use'))) { $source->forceReprocess(); } } } foreach ($this->collection as $item) { $item->data()->set('next_' . $this->dataSingularName, $item->nextItem()); $item->data()->set('previous_' . $this->dataSingularName, $item->previousItem()); } }