You are here

public static function HookImplementations::warmBatch in Warmer 8

Same name and namespace in other branches
  1. 2.x src/HookImplementations.php \Drupal\warmer\HookImplementations::warmBatch()

Warms one batch of items based on their IDs.

Parameters

mixed $ids: The ID.

string $warmer_id: The warmer plugin ID.

Return value

int The number of successfully warmed items.

Throws

\Drupal\Component\Plugin\Exception\PluginException

File

src/HookImplementations.php, line 70

Class

HookImplementations
Helper functions to use in hook implementations.

Namespace

Drupal\warmer

Code

public static function warmBatch(array $ids, $warmer_id) {

  /** @var \Drupal\warmer\Plugin\WarmerPluginManager $warmer_manager */
  $warmer_manager = \Drupal::service('plugin.manager.warmer');

  /** @var \Drupal\warmer\Plugin\WarmerInterface $warmer */
  $warmer = $warmer_manager
    ->createInstance($warmer_id);
  $items = $warmer
    ->loadMultiple($ids);
  return $warmer
    ->warmMultiple($items);
}