You are here

public static function EntityExportFormBuilder::getEntitiesFromBundle in Content Synchronizer 3.x

Same name and namespace in other branches
  1. 8.2 src/Service/EntityExportFormBuilder.php \Drupal\content_synchronizer\Service\EntityExportFormBuilder::getEntitiesFromBundle()
  2. 8 src/Service/EntityExportFormBuilder.php \Drupal\content_synchronizer\Service\EntityExportFormBuilder::getEntitiesFromBundle()

Get the list of entities from a bundle entity.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityBundleBase $entity: The bundle entity.

Return value

\Drupal\Core\Entity\EntityInterface[]|null The entities of the bundle.

2 calls to EntityExportFormBuilder::getEntitiesFromBundle()
EntityExportFormBuilder::onAddToExport in src/Service/EntityExportFormBuilder.php
Add entity to an existing entity export.
QuickExportController::quickExport in src/Controller/QuickExportController.php
Launch quick export batch.

File

src/Service/EntityExportFormBuilder.php, line 238

Class

EntityExportFormBuilder
The entity export form builder.

Namespace

Drupal\content_synchronizer\Service

Code

public static function getEntitiesFromBundle(ConfigEntityBundleBase $entity) {
  $entityType = $entity
    ->getEntityType()
    ->getBundleOf();
  $bundleKey = \Drupal::entityTypeManager()
    ->getDefinitions()[$entityType]
    ->getKeys()['bundle'];
  $query = \Drupal::entityQuery($entityType)
    ->condition($bundleKey, $entity
    ->id());
  $entitiesIds = $query
    ->execute();
  if (!empty($entitiesIds)) {
    return \Drupal::entityTypeManager()
      ->getStorage($entityType)
      ->loadMultiple($entitiesIds);
  }
  return NULL;
}