You are here

ViewRevisionsUI.php in Config Entity Revisions 8.2

File

modules/view_revisions/src/ViewRevisionsUI.php
View source
<?php

namespace Drupal\view_revisions;

use Drupal\views_ui\ViewUI;
use Drupal\config_entity_revisions\ConfigEntityRevisionsConfigEntityContainerInterface;

/**
 * Class ViewRevisionsUI.
 *
 * @package Drupal\view_revisions
 */
class ViewRevisionsUI extends ViewUI implements ConfigEntityRevisionsConfigEntityContainerInterface {

  /**
   * Sets a cached view object in the shared tempstore.
   */
  public function cacheSet() {
    if ($this
      ->isLocked()) {
      \Drupal::messenger()
        ->addMessage(t('Changes cannot be made to a locked view.'), 'error');
      return;
    }

    // Let any future object know that this view has changed.
    $this->changed = TRUE;
    $executable = $this
      ->getExecutable();
    if (isset($executable->current_display)) {

      // Add the knowledge of the changed display, too.
      $this->changed_display[$executable->current_display] = TRUE;
      $executable->current_display = NULL;
    }

    // Unset handlers. We don't want to write these into the cache.
    $executable->display_handler = NULL;
    $executable->default_display = NULL;
    $executable->query = NULL;
    $executable->displayHandlers = NULL;
    $revId = $this
      ->get('storage')
      ->get('loadedRevisionId');
    $cacheId = $revId ? $this
      ->id() . '-' . $revId : $this
      ->id();
    $this->storage->entityTypeManager = NULL;
    $this->entityTypeManager = NULL;
    \Drupal::service('tempstore.shared')
      ->get('views')
      ->set($cacheId, $this);
  }

  /**
   * Get the revisioned entity (storage in this case).
   *
   * @return \Drupal\Core\Config\Entity\ConfigEntityBase
   *   The revisioned config entity.
   */
  public function revisionedEntity() {
    return $this
      ->get('storage');
  }

}

Classes

Namesort descending Description
ViewRevisionsUI Class ViewRevisionsUI.