You are here

function drush_social_demo_demo_content_remove in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  2. 8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  3. 8.3 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  4. 8.4 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  5. 8.5 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  6. 8.6 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  7. 8.7 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  8. 8.8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  9. 10.3.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  10. 10.0.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  11. 10.1.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()
  12. 10.2.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_remove()

Removes demo content.

1 string reference to 'drush_social_demo_demo_content_remove'
drush_social_demo_remove in modules/custom/social_demo/social_demo.drush.inc
Remove demo content.

File

modules/custom/social_demo/social_demo.drush.inc, line 102
Contains social_demo.drush.inc.

Code

function drush_social_demo_demo_content_remove() {
  \Drupal::currentUser()
    ->setAccount(User::load(1));
  $content_types = func_get_args();
  $profile = drush_get_option('profile', '');
  $manager = \Drupal::service('plugin.manager.demo_content');
  $plugins = $manager
    ->createInstances($content_types);

  /** @var \Drupal\social_demo\DemoContentInterface $plugin */
  foreach ($plugins as $plugin) {
    $definition = $plugin
      ->getPluginDefinition();
    $plugin
      ->setProfile($profile);
    $plugin
      ->removeContent();
    drush_log("{$definition['label']}(s) removed", LogLevel::SUCCESS);
  }
}