You are here

public function ViewListController::getOperations in Views (for Drupal 7) 8.3

Implements Drupal\Core\Entity\EntityListController::getOperations();

File

views_ui/lib/Drupal/views_ui/ViewListController.php, line 84
Definition of Drupal\views_ui\ViewListController.

Class

ViewListController
Provides a listing of Views.

Namespace

Drupal\views_ui

Code

public function getOperations(EntityInterface $view) {
  $uri = $view
    ->uri();
  $path = $uri['path'] . '/view/' . $view
    ->id();
  $definition['edit'] = array(
    'title' => t('Edit'),
    'href' => "{$path}/edit",
    'weight' => -5,
  );
  if (!$view
    ->isEnabled()) {
    $definition['enable'] = array(
      'title' => t('Enable'),
      'ajax' => TRUE,
      'token' => TRUE,
      'href' => "{$path}/enable",
      'weight' => -10,
    );
  }
  else {
    $definition['disable'] = array(
      'title' => t('Disable'),
      'ajax' => TRUE,
      'token' => TRUE,
      'href' => "{$path}/disable",
      'weight' => 0,
    );
  }

  // This property doesn't exist yet.
  if (!empty($view->overridden)) {
    $definition['revert'] = array(
      'title' => t('Revert'),
      'href' => "{$path}/revert",
      'weight' => 5,
    );
  }
  else {
    $definition['delete'] = array(
      'title' => t('Delete'),
      'href' => "{$path}/delete",
      'weight' => 10,
    );
  }
  return $definition;
}