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

DDST-70: Fix use of batch methods from decorated services. #1027

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/Form/AddChildrenWizard/AbstractFileSelectionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,46 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$builder = (new BatchBuilder())
->setTitle($this->t('Bulk creating...'))
->setInitMessage($this->t('Initializing...'))
->setFinishCallback([$this->batchProcessor, 'batchProcessFinished']);
->setFinishCallback([$this, 'batchProcessFinished']);
$values = $form_state->getValue($this->getField($cached_values)->getName());
$massaged_values = $widget->massageFormValues($values, $form, $form_state);
foreach ($massaged_values as $delta => $info) {
$builder->addOperation(
[$this->batchProcessor, 'batchOperation'],
[$this, 'batchOperation'],
[$delta, $info, $cached_values]
);
}
batch_set($builder->toArray());
}

/**
* Wrap batch processor operation call to side-step serialization issues.
*
* Previously, we referred to the method on the processors directly; however,
* this can lead to issues regarding the (un)serialization of the services as
* which the processors are implemented. For example, if decorating one of the
* processors to extend it, it loses the reference back to be able to load the
* "inner"/decorated processor.
*
* @see \Drupal\islandora\Form\AddChildrenWizard\AbstractBatchProcessor::batchOperation()
*/
public function batchOperation($delta, $info, $cached_values, &$context) : void {
$this->batchProcessor->batchOperation($delta, $info, $cached_values, $context);
}

/**
* Wrap batch processor finished call to side-step serialization issues.
*
* Previously, we referred to the method on the processors directly; however,
* this can lead to issues regarding the (un)serialization of the services as
* which the processors are implemented. For example, if decorating one of the
* processors to extend it, it loses the reference back to be able to load the
* "inner"/decorated processor.
*
* @see \Drupal\islandora\Form\AddChildrenWizard\AbstractBatchProcessor::batchProcessFinished()
*/
public function batchProcessFinished($success, $results, $operations) : void {
$this->batchProcessor->batchProcessFinished($success, $results, $operations);
}

}
Loading