You are here

protected function SqlBase::mapJoinable in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Plugin/migrate/source/SqlBase.php \Drupal\migrate\Plugin\migrate\source\SqlBase::mapJoinable()

Check if we can join against the map table.

This function specifically catches issues when we're migrating with unique sets of credentials for the source and destination database.

Return value

bool TRUE if we can join against the map table otherwise FALSE.

2 calls to SqlBase::mapJoinable()
SqlBase::initializeIterator in core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
Implementation of MigrateSource::performRewind().
TestSqlBase::mapJoinable in core/modules/migrate/tests/src/Unit/SqlBaseTest.php
Checks if we can join against the map table.
1 method overrides SqlBase::mapJoinable()
TestSqlBase::mapJoinable in core/modules/migrate/tests/src/Unit/SqlBaseTest.php
Checks if we can join against the map table.

File

core/modules/migrate/src/Plugin/migrate/source/SqlBase.php, line 252
Contains \Drupal\migrate\Plugin\migrate\source\SqlBase.

Class

SqlBase
Sources whose data may be fetched via DBTNG.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

protected function mapJoinable() {
  if (!$this
    ->getIds()) {
    return FALSE;
  }
  $id_map = $this->migration
    ->getIdMap();
  if (!$id_map instanceof Sql) {
    return FALSE;
  }
  $id_map_database_options = $id_map
    ->getDatabase()
    ->getConnectionOptions();
  $source_database_options = $this
    ->getDatabase()
    ->getConnectionOptions();
  foreach (array(
    'username',
    'password',
    'host',
    'port',
    'namespace',
    'driver',
  ) as $key) {
    if (isset($source_database_options[$key])) {
      if ($id_map_database_options[$key] != $source_database_options[$key]) {
        return FALSE;
      }
    }
  }
  return TRUE;
}