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

Breadcrumb

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

function Connection::getProvider

Get the module name of the module that is providing the database driver.

Return value

string The module name of the module that is providing the database driver, or "core" when the driver is not provided as part of a module.

File

core/lib/Drupal/Core/Database/Connection.php, line 1426

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function getProvider() : string {
    [
        $first,
        $second,
    ] = explode('\\', $this->connectionOptions['namespace'], 3);
    // The namespace for Drupal modules is Drupal\MODULE_NAME, and the module
    // name must be all lowercase. Second-level namespaces containing uppercase
    // letters (e.g., "Core", "Component", "Driver") are not modules.
    // @see \Drupal\Core\DrupalKernel::getModuleNamespacesPsr4()
    // @see https://www.drupal.org/docs/8/creating-custom-modules/naming-and-placing-your-drupal-8-module#s-name-your-module
    return $first === 'Drupal' && strtolower($second) === $second ? $second : 'core';
}
RSS feed
Powered by Drupal