You are here

public function SmartSql::__construct in Smart SQL ID Map 1.1.x

Same name and namespace in other branches
  1. 1.0.x src/Plugin/migrate/id_map/SmartSql.php \Drupal\smart_sql_idmap\Plugin\migrate\id_map\SmartSql::__construct()

Overrides Sql::__construct

See also

https://drupal.org/i/2845340

1 call to SmartSql::__construct()
TestSmartSqlIdMap::__construct in tests/src/Unit/TestSmartSqlIdMap.php
Constructs a TestSqlIdMap object.
1 method overrides SmartSql::__construct()
TestSmartSqlIdMap::__construct in tests/src/Unit/TestSmartSqlIdMap.php
Constructs a TestSqlIdMap object.

File

src/Plugin/migrate/id_map/SmartSql.php, line 24

Class

SmartSql
A smart, sql based ID map.

Namespace

Drupal\smart_sql_idmap\Plugin\migrate\id_map

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
  parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher);

  // Default generated table names, limited to 63 characters.
  $machine_name = str_replace(PluginBase::DERIVATIVE_SEPARATOR, '__', $this->migration
    ->id());
  $prefix_length = strlen($this->database
    ->tablePrefix());
  $map_table_name = 'm_map_' . mb_strtolower($machine_name);
  $this->mapTableName = mb_substr($map_table_name, 0, 63 - $prefix_length) === $map_table_name ? $map_table_name : mb_substr($map_table_name, 0, 45 - $prefix_length) . '_' . substr(md5($machine_name), 0, 17);
  $message_table_name = 'm_message_' . mb_strtolower($machine_name);
  $this->messageTableName = mb_substr($message_table_name, 0, 63 - $prefix_length) === $message_table_name ? $message_table_name : mb_substr($message_table_name, 0, 45 - $prefix_length) . '_' . substr(md5($machine_name), 0, 17);
}