You are here

function views_revert_view in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 7.3 drush/views.drush.inc \views_revert_view()

Revert a specified view

Parameters

$view: The view object to be reverted

Checks on wether or not the view is overridden is handled in views_revert_views_revert() We perform a check here anyway in case someone somehow calls this function on their own...

2 calls to views_revert_view()
views_revert_allviews in ./views_revert.drush.inc
Reverts all views
views_revert_views in ./views_revert.drush.inc
Callback function for views-revert command.

File

./views_revert.drush.inc, line 139
views-revert - Drush command to revert views overridden in the system.

Code

function views_revert_view($view) {

  // check anyway just in case
  if ($view->type == t('Overridden')) {

    // Revert the view.
    $view
      ->delete();

    // Clear its cache.
    views_object_cache_clear('view', $view->name);

    // Give feedback.
    $message = dt("Reverted the view '@viewname'", array(
      '@viewname' => $view->name,
    ));
    drush_log($message, 'success');

    // Reverted one more view.
  }
  else {
    drush_set_error(dt("The view '@viewname' is not overridden.", array(
      '@viewname' => $view->name,
    )));
  }
}