function 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.

1 call to views_ui_cache_load()
ViewPreviewFormController::submitPreview in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewPreviewFormController.php
Form submission handler for the Preview button.

File

drupal/core/modules/views/views_ui/views_ui.module, line 338
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
        ->set('disabled', $original_view
        ->get('disabled'));
    }
  }
  if (empty($view)) {
    return FALSE;
  }
  $view->locked = $views_temp_store
    ->getMetadata($view
    ->get('name'));
  return $view;
}