function drush_sync_enable_post_sql_sync

8.0.x sync_enable.drush.inc drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL)
6.x sync_enable.drush.inc drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL)
7.x sync_enable.drush.inc drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL)
5.x sync_enable.drush.inc drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL)
master sync_enable.drush.inc drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL)

Implement hook post sql sync.

The post hook is only called if the sql-sync operation completes without an error. When called, we check to see if the user specified any modules to enable/disable. If so, we will call pm-enable/pm-disable on each module.

File

examples/sync_enable.drush.inc, line 67

Code

function drush_sync_enable_post_sql_sync($source = NULL, $destination = NULL) {
  $modules_to_enable = drush_get_option_list('enable');
  if (!empty($modules_to_enable)) {
    drush_log(dt("Enable !modules post-sql-sync", array('!modules' => implode(',', $modules_to_enable))), 'ok');
    drush_invoke_process($destination, 'pm-enable', $modules_to_enable, array('yes' => TRUE));
  }
  $modules_to_disable = drush_get_option_list('disable');
  if (!empty($modules_to_disable)) {
    drush_log(dt("Disable !modules post-sql-sync", array('!modules' => implode(',', $modules_to_disable))), 'ok');
    drush_invoke_process($destination, 'pm-disable', $modules_to_disable, array('yes' => TRUE));
  }
  $permissions_table = drush_get_option('permission');
  if (!empty($permissions_table)) {
    foreach ($permissions_table as $role_name => $actions) {
      if (array_key_exists('add', $actions)) {
        $permissions_to_add = is_array($actions['add']) ? $actions['add'] : explode(', ', $actions['add']);
        foreach ($permissions_to_add as $permission) {
          $values = drush_invoke_process($destination, 'role-add-perm', array($role_name, $permission), array(), array('integrate' => TRUE));
        }
      }
      if (array_key_exists('remove', $actions)) {
        $permissions_to_remove = is_array($actions['remove']) ? $actions['remove'] : explode(', ', $actions['remove']);
        foreach ($permissions_to_remove as $permission) {
          $values = drush_invoke_process($destination, 'role-remove-perm', array($role_name, $permission), array(), array('integrate' => TRUE));
        }
      }
    }
  }
}