public function EntityUpdateExec::submitFormSafe in Entity Update 2.0.x
Same name and namespace in other branches
- 8 src/Form/EntityUpdateExec.php \Drupal\entity_update\Form\EntityUpdateExec::submitFormSafe()
Run updates using safe (full) method.
File
- src/
Form/ EntityUpdateExec.php, line 234
Class
- EntityUpdateExec
- Class CheckEntityUpdate.
Namespace
Drupal\entity_update\FormCode
public function submitFormSafe(array &$form, FormStateInterface $form_state) {
try {
$type = $form_state
->getValue('entity_type_id');
$entity_type = entity_update_get_entity_type($type);
// Update the entity type.
$res = EntityUpdate::safeUpdateMain($entity_type);
$res_str = $res ? 'SUCCESS' : 'FAIL';
$status = $res ? 'status' : 'error';
$options = [
'@res' => $res_str,
'@type' => $entity_type
->getLabel(),
];
$this
->messenger()
->addMessage($this
->t("Entity @type update @res", $options), $status);
} catch (\Exception $e) {
$this
->messenger()
->addMessage($this
->t("Entity update Fail"), 'error');
$this
->messenger()
->addMessage($e
->getMessage(), 'error');
}
}