Projet

Général

Profil

Révision 6f57d8c7

Ajouté par Assos Assos il y a environ 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/drush/views.drush.inc
42 42
    ),
43 43
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
44 44
    'aliases' => array('vr'),
45
    'options' => array(
46
      'all' => 'If provided, all views will be reverted.',
47
    ),
45 48
    'examples' => array(
46 49
      'drush vr archive' => 'Reverts the "archive" view.',
47 50
      'drush rln archive frontpage' => 'Reverts the "archive" and "frontpage" view.',
48 51
      'drush vr' => 'Will present you with a list of overridden views to choose from, and an option to revert all overridden views.',
52
      'drush vr --all' => 'Will revert all overridden views.',
49 53
    ),
50 54
  );
51 55
  $items['views-dev'] = array(
......
126 130
    }
127 131
  }
128 132

  
129
  // Return early if there are no overridden views in the system.
133
  // If there are no overridden views in the system, report it.
130 134
  if (empty($overridden)) {
131
    return drush_set_error(dt('There are no overridden views in the system.'));
135
    drush_log(dt('There are no overridden views in the system.'), 'ok');
132 136
  }
133 137

  
134
  // If the user specified in the command the views to be overridden.
135
  if (!empty($viewnames)) {
138
  // If the user provided the "--all" option, revert all views.
139
  if (drush_get_option('all')) {
140
    $i = views_revert_allviews($views);
141
  }
142

  
143
  // If the user specified a list of views on the CLI, revert those.
144
  elseif (!empty($viewnames)) {
136 145
    foreach ($viewnames as $key => $viewname) {
137 146
      $is_overridden = key_exists($viewname, $overridden);
147

  
138 148
      // Check if the provided view name is in the system
139 149
      if ($viewname && !key_exists($viewname, $views)) {
140 150
        drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname)));
......
144 154
        drush_set_error(dt("The view specified '@viewname' is not overridden.", array('@viewname' => $viewname)));
145 155
      }
146 156
      // If the view is overriden, revert it.
147
      elseif ($is_overridden){
157
      elseif ($is_overridden) {
148 158
        views_revert_view($views[$viewname]);
149 159
        $i++;
150 160
      }
151 161
      // We should never get here but well...
152 162
      else {
153
        drush_set_error(dt("The view specified '@viewname' is not provided in code, and thus cannot be reverted.", array('@viewname' => $viewname)));
163
        drush_set_error(dt(
164
          "The view specified '@viewname' is not provided in code, and thus cannot be reverted.",
165
          array('@viewname' => $viewname)
166
        ));
154 167
      }
155 168
    }
156 169
  }
157 170

  
158
  // The user did not specify any views in the command, prompt the user
171
  // The user neither selected the "--all" option, nor provided a list of views to revert.
172
  // Prompt the user.
159 173
  else {
160 174
    // list of choices for the user
161 175
    $overridden['all'] = dt('Revert all overridden views'); // add a choice at the end

Formats disponibles : Unified diff