function SqlBase::getDatabase
Gets the database connection object.
Return value
\Drupal\Core\Database\Connection The database connection.
3 calls to SqlBase::getDatabase()
- File::query in core/modules/ file/ src/ Plugin/ migrate/ source/ d7/ File.php 
- SqlBase::checkRequirements in core/modules/ migrate/ src/ Plugin/ migrate/ source/ SqlBase.php 
- Checks if requirements for this plugin are OK.
- TestSqlBase::getDatabase in core/modules/ migrate/ tests/ src/ Kernel/ SqlBaseTest.php 
- Gets the database without caching it.
2 methods override SqlBase::getDatabase()
- TestSqlBase::getDatabase in core/modules/ migrate/ tests/ src/ Unit/ SqlBaseTest.php 
- Gets the database connection object.
- TestSqlBase::getDatabase in core/modules/ migrate/ tests/ src/ Kernel/ SqlBaseTest.php 
- Gets the database without caching it.
File
- 
              core/modules/ migrate/ src/ Plugin/ migrate/ source/ SqlBase.php, line 145 
Class
- SqlBase
- Sources whose data may be fetched via a database connection.
Namespace
Drupal\migrate\Plugin\migrate\sourceCode
public function getDatabase() {
  if (!isset($this->database)) {
    // Look first for an explicit state key containing the configuration.
    if (isset($this->configuration['database_state_key'])) {
      $this->database = $this->setUpDatabase($this->state
        ->get($this->configuration['database_state_key']));
    }
    elseif (isset($this->configuration['key'])) {
      $this->database = $this->setUpDatabase($this->configuration);
    }
    elseif ($fallback_state_key = $this->state
      ->get('migrate.fallback_state_key')) {
      $this->database = $this->setUpDatabase($this->state
        ->get($fallback_state_key));
    }
    else {
      $this->database = $this->setUpDatabase([]);
    }
  }
  return $this->database;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
