public function DiffFrom::viewsFormSubmit in Diff 8
Submit handler for the bulk form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Throws
\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException Thrown when the user tried to access an action without access to it.
File
- src/
Plugin/ views/ field/ DiffFrom.php, line 63
Class
- DiffFrom
- Provides View field diff from plugin.
Namespace
Drupal\diff\Plugin\views\fieldCode
public function viewsFormSubmit(array &$form, FormStateInterface $form_state) {
if ($form_state
->get('step') == 'views_form_views_form') {
$diff_from = $form_state
->getValue($this->options['id']);
$diff_from_entity = $this
->loadEntityFromDiffFormKey($diff_from);
$diff_to = $form_state
->getValue($this
->getToFieldId());
$diff_to_entity = $this
->loadEntityFromDiffFormKey($diff_to);
$options = array(
'query' => $this
->getDestinationArray(),
);
$entity_type_id = $diff_from_entity
->getEntityTypeId();
$filter = \Drupal::service('plugin.manager.diff.layout')
->getDefaultLayout();
if ($diff_from_entity instanceof NodeInterface && $diff_to_entity instanceof NodeInterface) {
$form_state
->setRedirect('diff.revisions_diff', [
$entity_type_id => $diff_from_entity
->id(),
'left_revision' => $diff_from_entity
->getRevisionId(),
'right_revision' => $diff_to_entity
->getRevisionId(),
'filter' => $filter,
], $options);
}
elseif ($diff_from_entity instanceof RevisionableInterface && $diff_to_entity instanceof RevisionableInterface) {
$route_name = 'entity.' . $entity_type_id . '.revisions_diff';
$form_state
->setRedirect($route_name, [
$entity_type_id => $diff_from_entity
->id(),
'left_revision' => $diff_from_entity
->getRevisionId(),
'right_revision' => $diff_to_entity
->getRevisionId(),
'filter' => $filter,
], $options);
}
}
}