function drush_social_demo_demo_content_add in Open Social 8.2
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.3 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.4 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.5 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.6 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.7 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 8.8 modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 10.3.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 10.0.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 10.1.x modules/custom/social_demo/social_demo.drush.inc \drush_social_demo_demo_content_add()
- 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);
    }
  }
}