public function UpdateEncryptionProfileForm::submitForm in Field Encryption 3.0.x
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ UpdateEncryptionProfileForm.php, line 127
Class
- UpdateEncryptionProfileForm
- Confirmation form for updating encryption on an entity.
Namespace
Drupal\field_encrypt\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Get entities that need updating.
$query = $this->entityTypeManager
->getStorage($this->entityType
->id())
->getQuery();
$query
->condition(ProcessEntities::ENCRYPTED_FIELD_STORAGE_NAME . '.encryption_profile', $this->encryptionProfile
->id());
// Make sure to get all revisions for revisionable entities.
if ($this->entityType
->isRevisionable()) {
$query
->allRevisions();
}
$entity_ids = $query
->execute();
if (!empty($entity_ids)) {
// Call the Queue API and add items for processing.
$data = [
'entity_type' => $this->entityType
->id(),
];
foreach (array_keys($entity_ids) as $entity_id) {
$data['entity_id'] = $entity_id;
$this->queue
->createItem($data);
}
}
$this
->messenger()
->addStatus($this
->formatPlural(count($entity_ids), 'Queued one %entity_type update. You should immediately <a href=":url">run this process manually</a>. Alternatively, the update will be performed automatically by cron.', 'Queued @count @entity_type updates. You should immediately <a href=":url">run this process manually</a>. Alternatively, the updates will be performed automatically by cron.', [
'@entity_type' => $this->entityType
->getSingularLabel(),
':url' => Url::fromRoute('field_encrypt.process_queue')
->toString(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}