--- allow_manual_imports-2640734-38.patch	2017-02-24 11:25:14.017995559 +0100
+++ allow_manual_imports-2640734-41.patch	2017-02-24 11:27:10.443249934 +0100
@@ -1,8 +1,8 @@
 diff --git a/drush/default_content.drush.inc b/drush/default_content.drush.inc
-index c062ca2..afb1591 100644
+index 1f89cb4..f018d7d 100644
 --- a/drush/default_content.drush.inc
 +++ b/drush/default_content.drush.inc
-@@ -5,6 +5,9 @@
+@@ -6,6 +6,9 @@ use Drupal\user\Entity\User;
   * Drush integration for the default_content module.
   */
  
@@ -12,12 +12,15 @@ index c062ca2..afb1591 100644
  /**
   * Implements hook_drush_command().
   */
-@@ -41,6 +44,22 @@ function default_content_drush_command() {
+@@ -47,6 +50,31 @@ function default_content_drush_command() {
      'aliases' => ['dcem'],
      'required-arguments' => 1,
    ];
 +  $items['default-content-export-modules'] = [
 +    'description' => dt('Exports all the content defined in all enabled modules.'),
++    'options' => [
++      'run-as' => dt('Run as a particular user (uid)'),
++    ],
 +    'aliases' => ['dcea'],
 +  ];
 +  $items['default-content-import-module'] = [
@@ -25,17 +28,23 @@ index c062ca2..afb1591 100644
 +    'arguments' => [
 +      'module' => dt('The name of the module or profile to import.'),
 +    ],
++    'options' => [
++      'run-as' => dt('Run as a particular user (uid)'),
++    ],
 +    'aliases' => ['dcim'],
 +    'required-arguments' => 1,
 +  ];
 +  $items['default-content-import-modules'] = [
 +    'description' => dt('Imports the content provided by installed modules and default profile.'),
++    'options' => [
++      'run-as' => dt('Run as a particular user (uid)'),
++    ],
 +    'aliases' => ['dcia'],
 +  ];
  
    return $items;
  }
-@@ -93,15 +112,117 @@ function drush_default_content_export_references($entity_type_id, $entity_id = N
+@@ -103,21 +131,125 @@ function drush_default_content_export_references($entity_type_id, $entity_id = N
  }
  
  /**
@@ -64,6 +73,7 @@ index c062ca2..afb1591 100644
 +    $modules = array_keys(\Drupal::config('core.extension')->get('module'));
 +  }
 +
+   _drush_default_content_setup();
    /** @var \Drupal\default_content\DefaultContentManagerInterface $manager */
    $manager = \Drupal::service('default_content.manager');
 -  $serialized_by_type = $manager->exportModuleContent($module_name);
@@ -93,6 +103,7 @@ index c062ca2..afb1591 100644
 +  else {
 +    drush_log(dt('No content has been exported.'), LogLevel::WARNING);
 +  }
++  _drush_default_content_teardown();
 +}
 +
 +/**
@@ -124,6 +135,7 @@ index c062ca2..afb1591 100644
 +    }
 +  }
 +
++  _drush_default_content_setup();
 +  $default_content_manager = \Drupal::service('default_content.manager');
 +  $total = 0;
 +  foreach ($modules as $module) {
@@ -140,8 +152,9 @@ index c062ca2..afb1591 100644
 +  else {
 +    drush_log(dt('No content has been imported.'), LogLevel::WARNING);
 +  }
-+}
-+
+   _drush_default_content_teardown();
+ }
+ 
 +/**
 + * Validates that a module or a profile exists and is installed.
 + *
@@ -156,4 +169,11 @@ index c062ca2..afb1591 100644
 +  return \Drupal::moduleHandler()->moduleExists($module) || $module === drupal_get_profile() ?
 +    TRUE :
 +    drush_set_error('INVALID_MODULE', dt("Module or profile '@module' doesn't exist or is uninstalled.", ['@module' => $module]));
- }
++}
++
+ /**
+  * Check "run-as" option and switch user if given.
+  *
+-- 
+2.11.0
+
