You are here

function drush_social_demo_demo_content_add 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_add()
  2. 8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  3. 8.3 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  4. 8.4 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  5. 8.5 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  6. 8.6 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  7. 8.7 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  8. 8.8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  9. 10.3.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  10. 10.0.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  11. 10.1.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
  12. 10.2.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()

Creates demo content.

1 string reference to 'drush_social_demo_demo_content_add'
drush_social_demo_add in modules/custom/social_demo/social_demo.drush.inc
Add demo content.

File

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

Code

function drush_social_demo_demo_content_add() {
  \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
      ->createContent();
    $count = $plugin
      ->count();
    if ($count !== FALSE) {
      drush_log("{$count} {$definition['label']}(s) created", LogLevel::SUCCESS);
    }
  }
}