You are here

trait ConfigEntityRevisionsEditFormTrait in Config Entity Revisions 8.2

Trait ConfigEntityRevisionsEditFormTrait.

@package Drupal\config_entity_revisions

Hierarchy

2 files declare their use of ConfigEntityRevisionsEditFormTrait
ViewRevisionsEditForm.php in modules/view_revisions/src/ViewRevisionsEditForm.php
WebformRevisionsEditForm.php in modules/webform_revisions/src/WebformRevisionsEditForm.php

File

src/ConfigEntityRevisionsEditFormTrait.php, line 12

Namespace

Drupal\config_entity_revisions
View source
trait ConfigEntityRevisionsEditFormTrait {

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    parent::save($form, $form_state);
    $entity = $this
      ->getEntity();
    if ($entity instanceof ConfigEntityRevisionsConfigEntityContainerInterface) {
      $revId = $entity
        ->revisionedEntity()
        ->get('loadedRevisionId');
      $cacheId = $revId ? $entity
        ->id() . '-' . $revId : $entity
        ->id();
      $this->tempStore
        ->delete($cacheId);
    }
  }

  /**
   * Form submission handler for the 'cancel' action.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function cancel(array $form, FormStateInterface $form_state) {

    // Remove this view from cache so edits will be lost.
    parent::cancel($form, $form_state);
    $entity = $this
      ->getEntity();
    if ($entity instanceof ConfigEntityRevisionsConfigEntityContainerInterface) {
      $revId = $entity
        ->revisionedEntity()
        ->get('loadedRevisionId');
      $cacheId = $revId ? $entity
        ->id() . '-' . $revId : $entity
        ->id();
      $this->tempStore
        ->delete($cacheId);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityRevisionsEditFormTrait::cancel public function Form submission handler for the 'cancel' action.
ConfigEntityRevisionsEditFormTrait::save public function