You are here

public static function ConvertBundles::getEntities in Convert Bundles 8

1 call to ConvertBundles::getEntities()
ConvertBundlesForm::submitForm in src/Form/ConvertBundlesForm.php
Form submission handler.

File

src/ConvertBundles.php, line 16

Class

ConvertBundles
ConvertBundles.

Namespace

Drupal\convert_bundles

Code

public static function getEntities($type, $bundles) {

  // Get the entity IDs to update.
  $definition = \Drupal::entityTypeManager()
    ->getDefinition($type);
  $column = $definition
    ->getKey('bundle');
  $query = \Drupal::entityQuery($type);
  $query
    ->condition($column, $bundles, 'IN');
  $ids = $query
    ->execute();
  $entities = [];
  foreach ($ids as $id) {
    $entities[$id] = \Drupal::entityTypeManager()
      ->getStorage($type)
      ->load($id);
  }
  return $entities;
}