You are here

public function MetatagFieldInstance::initializeIterator in Metatag 8

Returns each entity_type/bundle pair.

Overrides SqlBase::initializeIterator

File

src/Plugin/migrate/source/d7/MetatagFieldInstance.php, line 105

Class

MetatagFieldInstance
Drupal 7 Metatag field instances.

Namespace

Drupal\metatag\Plugin\migrate\source\d7

Code

public function initializeIterator() {
  $bundles = [];
  foreach (parent::initializeIterator() as $instance) {

    // For entity types for which we support creating derivatives, do not
    // retrieve the bundles using the D8|9 entity type bundle info service,
    // because then we will end up creating meta tag fields even for bundles
    // that do not use meta tags.
    if (isset($instance['bundle'])) {
      $bundles[] = $instance;
      continue;
    }
    $bundle_info = $this->entityTypeBundleInfo
      ->getBundleInfo($instance['entity_type']);
    foreach (array_keys($bundle_info) as $bundle) {
      $bundles[] = [
        'entity_type' => $instance['entity_type'],
        'bundle' => $bundle,
      ];
    }
  }
  return new \ArrayIterator($bundles);
}