You are here

public function MigrationController::getOverriddenFields in Workbench Moderation to Content Moderation 8.2

Returns all moderation_state base field overrides.

Return value

BaseFieldOverride[] The overridden moderation_state field definitions.

File

src/MigrationController.php, line 160

Class

MigrationController

Namespace

Drupal\wbm2cm

Code

public function getOverriddenFields() {
  $overridden = [];
  $bundle_info = $this->entityTypeBundleInfo
    ->getAllBundleInfo();
  foreach ($bundle_info as $entity_type_id => $bundles) {

    // Ignore non-fieldable entity types.
    $entity_type = $this->entityTypeManager
      ->getDefinition($entity_type_id);
    if (!$entity_type
      ->entityClassImplements(FieldableEntityInterface::class)) {
      continue;
    }
    foreach (array_keys($bundles) as $bundle) {
      $fields = $this->entityFieldManager
        ->getFieldDefinitions($entity_type_id, $bundle);
      if (isset($fields['moderation_state']) && $fields['moderation_state'] instanceof BaseFieldOverride) {
        array_push($overridden, $fields['moderation_state']);
      }
    }
  }
  return $overridden;
}