Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SqlBase.php

function SqlBase::getDatabase

Gets the database connection object.

Return value

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

2 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.

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\source

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal