public static function createDemoContent($pluginId, array &$context) {
    // Reset time limit so we don't timeout.
    drupal_set_time_limit(0);

    // Needs to be resolved manually since we don't have a context.
    /** @var \Drupal\presto\Installer\DemoContentManager $demoContentManager */
    $demoContentManager = Drupal::service(
      'plugin.manager.presto.demo_content'
    );

    $definition = $demoContentManager->getDefinition($pluginId);
    /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
    $label = $definition['label'];

    /** @var \Drupal\presto\Plugin\Presto\DemoContent\AbstractDemoContent $instance */
    $instance = $demoContentManager->createInstance($pluginId);
    $instance->createContent();

    $context['results'][] = $pluginId;
    $context['message'] = t('Running %task_name', [
      '%task_name' => lcfirst($label->render()),
    ]);
  }
public static function createDemoContent($pluginId, array &$context) {
    // Reset time limit so we don't timeout.
    drupal_set_time_limit(0);

    // Needs to be resolved manually since we don't have a context.
    /** @var \Drupal\presto\Installer\DemoContentManager $demoContentManager */
    $demoContentManager = Drupal::service(
      'plugin.manager.presto.demo_content'
    );

    $definition = $demoContentManager->getDefinition($pluginId);
    /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
    $label = $definition['label'];

    /** @var \Drupal\presto\Plugin\Presto\DemoContent\AbstractDemoContent $instance */
    $instance = $demoContentManager->createInstance($pluginId);
    $instance->createContent();

    $context['results'][] = $pluginId;
    $context['message'] = t('Running %task_name', [
      '%task_name' => lcfirst($label->render()),
    ]);
  }
public static function createDemoContent ( $ pluginId , array & $ context ) { // Reset time limit so we don't timeout. drupal_set_time_limit ( 0 ) ; // Needs to be resolved manually since we don't have a context. /** @var \Drupal\presto\Installer\DemoContentManager $demoContentManager */ $ demoContentManager = Drupal :: service ( 'plugin.manager.presto.demo_content' ) ; $ definition = $ demoContentManager -> getDefinition ( $ pluginId ) ; /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */ $ label = $ definition [ 'label' ] ; /** @var \Drupal\presto\Plugin\Presto\DemoContent\AbstractDemoContent $instance */ $ instance = $ demoContentManager -> createInstance ( $ pluginId ) ; $ instance -> createContent ( ) ; $ context [ 'results' ] [ ] = $ pluginId ; $ context [ 'message' ] = t ( 'Running %task_name' , [ '%task_name' => lcfirst ( $ label -> render ( ) ) , ] ) ; }
Creates a demo content item.

This is a Drupal batch callback operation and as such, needs to be both a
public and a static function so that the Batch API can access it outside
the context of this class.

@param string $pluginId
Demo content class plugin ID.
@param array $context
Batch context.

@throws \Drupal\Component\Plugin\Exception\PluginException
Creates a demo content item .