You are here

public static function MediaMigrateGenerator::validatePluginId in Migrate File Entities to Media Entities 8

Plugin id validator.

File

src/Generators/MediaMigrateGenerator.php, line 113

Class

MediaMigrateGenerator
Automatically generates yml files for migrations.

Namespace

Drupal\migrate_file_to_media\Generators

Code

public static function validatePluginId($value) {

  // Check the length of the global table name prefix.
  $db_info = array_shift(Database::getConnectionInfo());
  $db_info = Database::parseConnectionInfo($db_info);
  $max_length = 48 - strlen($db_info['prefix']['default']);

  // Check if the plugin machine name is valid.
  Utils::validateMachineName($value);

  // Check the maximum number of characters for the migration name. The name
  // should not exceed 48 characters to prevent mysql table name limitation of
  // 64 characters for the table: migrate_message_[PLUGIN_ID].
  if (strlen($value) > $max_length) {
    throw new \UnexpectedValueException('The plugin id should not exceed more than ' . strval($max_length) . ' characters.');
  }
  return $value;
}