You are here

public static function SourceDatabase::getTextFields in Media Migration 8

Returns the name of the text fields found in the given Drupal 7 database.

Parameters

\Drupal\Core\Database\Connection $connection: The database connection of the source Drupal 7 instance.

string|null $source_entity_type_id: The source entity type ID to filter for. Optional.

string|null $source_bundle: The source bundle to filter for. Optional.

Return value

string[] The field names of the active text fields found in the source database.

2 calls to SourceDatabase::getTextFields()
SourceDatabase::getFormatsHavingFileLink in src/Utility/SourceDatabase.php
Returns text formats which are formatting text with <a> pointing to a file.
SourceDatabase::getFormatsUsingTag in src/Utility/SourceDatabase.php
Returns text formats which are formatting the tag in a Drupal 7 instance.

File

src/Utility/SourceDatabase.php, line 30

Class

SourceDatabase
Utility class for source database specific routines.

Namespace

Drupal\media_migration\Utility

Code

public static function getTextFields(Connection $connection, ?string $source_entity_type_id = NULL, ?string $source_bundle = NULL) : array {
  if (!\Drupal::moduleHandler()
    ->moduleExists('text')) {
    return [];
  }
  $query = $connection
    ->select('field_config', 'fc')
    ->fields('fc', [
    'field_name',
  ])
    ->condition('fc.module', 'text')
    ->condition('fc.type', [
    'text',
    'text_long',
    'text_with_summary',
  ], 'IN')
    ->condition('fc.active', 1)
    ->condition('fc.storage_active', 1)
    ->condition('fc.deleted', 0)
    ->condition('fci.deleted', 0)
    ->groupBy('fc.field_name');
  if ($source_entity_type_id) {
    $query
      ->condition('fci.entity_type', $source_entity_type_id);
    if ($source_bundle) {
      $query
        ->condition('fci.bundle', $source_bundle);
    }
  }
  $query
    ->join('field_config_instance', 'fci', 'fc.id = fci.field_id');
  try {
    return $query
      ->execute()
      ->fetchCol();
  } catch (DatabaseExceptionWrapper $e) {
  }
  return [];
}