You are here

public function SqlBase::getDatabase 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::getDatabase()

Get the database connection object.

Return value

\Drupal\Core\Database\Connection The database connection.

1 call to SqlBase::getDatabase()
File::query in core/modules/file/src/Plugin/migrate/source/d7/File.php
1 method overrides SqlBase::getDatabase()
TestSqlBase::getDatabase in core/modules/migrate/tests/src/Unit/SqlBaseTest.php
Gets the database connection object.

File

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

Class

SqlBase
Sources whose data may be fetched via DBTNG.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

public function getDatabase() {
  if (!isset($this->database)) {

    // See if the database info is in state - if not, fallback to
    // configuration.
    if (isset($this->configuration['database_state_key'])) {
      $this->database = $this
        ->setUpDatabase($this->state
        ->get($this->configuration['database_state_key']));
    }
    else {
      $this->database = $this
        ->setUpDatabase($this->configuration);
    }
  }
  return $this->database;
}