You are here

function views_ui_cache_load in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 views_ui.module \views_ui_cache_load()
  2. 6.2 views_ui.module \views_ui_cache_load()
  3. 7.3 views_ui.module \views_ui_cache_load()

Specialized menu callback to load a view and check its locked status.

Parameters

$name: The machine name of the view.

Return value

The view object, with a "locked" property indicating whether or not someone else is already editing the view.

File

views_ui/views_ui.module, line 311
Provide structure for the administrative interface to Views.

Code

function views_ui_cache_load($name) {
  $views_temp_store = drupal_container()
    ->get('user.tempstore')
    ->get('views');
  $view = $views_temp_store
    ->get($name);
  $storage = entity_load('view', $name);
  $original_view = $storage ? new ViewUI($storage) : NULL;
  if (empty($view)) {
    $view = $original_view;
    if (!empty($view)) {

      // Check to see if someone else is already editing this view.
      // Set a flag to indicate that this view is being edited.
      // This flag will be used e.g. to determine whether strings
      // should be localized.
      $view->editing = TRUE;
    }
  }
  else {

    // Keep disabled/enabled status real.
    if ($original_view) {
      $view->storage->disabled = $original_view->storage->disabled;
    }
  }
  if (empty($view)) {
    return FALSE;
  }
  $view->locked = $views_temp_store
    ->getMetadata($view->storage->name);
  return $view;
}