It makes sense to use the CTools drush commands where possible as they work for any exportable. As views are exportables we can just invoke the CTools drush commands to do this for us. This means we have less code to maintain in the views.drush.inc (alot less!), which is always a win.

This patch basically changed the views-revert, views-enable, and views-disable commands to use one drush_views_exportable_ops() command that deals with all of them. From this command, the appropriate command(s) are invoked from the CTools code. So the view drush commands are just convenience wrappers for the CTools commands.

Here is an initial patch, there is much less code now :)

CommentFileSizeAuthor
views_drush_ctools_commands.patch7.68 KBdamiankloip
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Title: Refactor viewsds drush commands to use CTools drush commands for exportable actions » Refactor views drush commands to use CTools drush commands for exportable actions
swentel’s picture

Status: Needs review » Needs work
+++ b/drush/views.drush.incundefined
@@ -108,126 +110,26 @@ function views_drush_command() {
+  menu_rebuild();

Probably nitpicking here, but there's also this option to rebuild the menu router:

variable_set('menu_rebuild_needed', TRUE);

I'm a huge fan of this one, but this might not be really a big issue since we're invoking commands through drush. I usually have issues with menu_rebuild when calling that function in say a submit function of a form. Looks good to me other than that to me.

swentel’s picture

Status: Needs work » Needs review

Didn't mean to set this 'needs work'

damiankloip’s picture

Thanks swentel, I think you are right, much less of an issue as we are using the cli. However, if people think it's better to set the variable to invoke a menu rebuild on the next request, that's cool.

tim.plunkett’s picture

Status: Needs review » Needs work

Confession: today was the first time I used views-analyze. It's awesome!

I only had one problem:

$ drush help vr
Reverts views in the drupal installation that have been overriden. If no view names are specified, you will be presented with a list of overridden views to choose from. To revert all views, do not specify any
view names, and choose the option "All" from the options presented.

With the patch, this no longer works. It only gives you

$ drush vr
No object names entered. Would you like to try and revert all exportables of type views_view (y/n):

I always used that feature, and I'd rather not see it go.