public function ViewRevisionsPreviewForm::form in Config Entity Revisions 8.2
Gets the actual form array to be built.
Overrides ViewPreviewForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- modules/
view_revisions/ src/ ViewRevisionsPreviewForm.php, line 55
Class
- ViewRevisionsPreviewForm
- Class ViewRevisionsPreviewForm.
Namespace
Drupal\view_revisionsCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
// Modify the preview URL to the version with a revision ID.
$view = $this->entity;
$linkTemplates = $view
->get('storage')
->getEntityType()
->getLinkTemplates();
// foreach($linkTemplates as $name => $template) {
$old_uri = $view
->urlInfo('preview-form');
$route_parameters = $old_uri
->getRouteParameters();
$route_options = $old_uri
->getOptions();
// We can't replace the route name, so we need to replace the whole object.
$uri = Url::fromRoute('entity.view.preview_revision_form', $route_parameters, $route_options);
$uri
->setRouteParameter('revision_id', $this
->getRevisionId($view
->get('storage')));
$form['#action'] = $uri
->toString();
return $form;
}