public function ReplicationActionForm::submitForm in Deploy - Content Staging 8
Implements submitForm().
.
Overrides FormInterface::submitForm
File
- src/
Form/ ReplicationActionForm.php, line 181
Class
- ReplicationActionForm
- ReplicationActionForm class.
Namespace
Drupal\deploy\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Pass the abort flag to the ReplicationManager using runtime-only state,
// i.e. a static.
// @see \Drupal\workspace\ReplicatorManager
// @see \Drupal\workspace\Entity\Form\WorkspaceForm
$is_aborted_on_conflict = !$form_state
->hasValue('is_aborted_on_conflict') || $form_state
->getValue('is_aborted_on_conflict') === 'true';
drupal_static('workspace_is_aborted_on_conflict', $is_aborted_on_conflict);
$entity = $this
->getEntity($form_state);
/** @var \Drupal\replication\Entity\ReplicationLogInterface $response */
$response = \Drupal::service('workspace.replicator_manager')
->replicate($entity
->get('source')->entity, $entity
->get('target')->entity);
if ($response instanceof ReplicationLogInterface && $response
->get('ok')->value == TRUE) {
$entity
->set('replicated', REQUEST_TIME)
->save();
$this
->messenger()
->addMessage('Successful deployment.');
}
else {
$this
->messenger()
->addError('Deployment error. Check recent log messages for more details.');
}
}