function LoggedStatementsTrait::getDriverClass

Same name and namespace in other branches
  1. 10 core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php \Drupal\database_statement_monitoring_test\LoggedStatementsTrait::getDriverClass()
  2. 9 core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php \Drupal\database_statement_monitoring_test\LoggedStatementsTrait::getDriverClass()

File

core/modules/system/tests/modules/database_statement_monitoring_test/src/LoggedStatementsTrait.php, line 48

Class

LoggedStatementsTrait
Trait for Connection classes that can store logged statements.

Namespace

Drupal\database_statement_monitoring_test

Code

public function getDriverClass($class) {
  // Override because the base class uses reflection to determine namespace
  // based on object, which would break.
  $namespace = (new \ReflectionClass(get_parent_class($this)))->getNamespaceName();
  $driver_class = $namespace . '\\' . $class;
  if (class_exists($driver_class)) {
    return $driver_class;
  }
  elseif ($class == 'Condition') {
    return Condition::class;
  }
  return $class;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.