You are here

protected function MigrationHelper::getBundles in Inline Entity Form 8

Helper to get the bundles for an entity type.

This currently only works for nodes. To add other entity types add a new case to the switch statement below and either use a query to get the bundles or hard code the values for you source site.

Parameters

\Drupal\migrate\Plugin\MigrateSourceInterface $source_plugin: The source plugin.

string $entity_type: The entity type.

Return value

array The product types.

1 call to MigrationHelper::getBundles()
MigrationHelper::alterRow in src/MigrationHelper.php
Adds all bundles for the entity type to the row.

File

src/MigrationHelper.php, line 109

Class

MigrationHelper
Helper for migration hooks in inline_entity_form.module.

Namespace

Drupal\inline_entity_form

Code

protected function getBundles(MigrateSourceInterface $source_plugin, $entity_type) {
  $bundles = NULL;
  $connection = NULL;
  try {
    $connection = $source_plugin
      ->getDatabase();
  } catch (RequirementsException $e) {
  }
  if ($connection) {
    switch ($entity_type) {
      case 'node':
        if ($connection
          ->schema()
          ->tableExists('node_type')) {
          $query = $connection
            ->select('node_type', 't')
            ->fields('t');
          $bundles = $query
            ->execute()
            ->fetchCol();
        }
        break;
      default:
        break;
    }
  }
  return $bundles;
}