getDatabaseErrors example

$reflection = new \ReflectionClass($drivers[$driver]);
    $install_namespace = $reflection->getNamespaceName();
    // Cut the trailing \Install from namespace.     $database['namespace'] = substr($install_namespace, 0, strrpos($install_namespace, '\\'));
    $database['driver'] = $driver;
    // See default.settings.php for an explanation of the 'autoload' key.     if ($autoload = Database::findDriverAutoloadDirectory($database['namespace'], DRUPAL_ROOT)) {
      $database['autoload'] = $autoload;
    }

    $form_state->set('database', $database);
    foreach ($this->getDatabaseErrors($database$form_state->getValue('settings_file')) as $name => $message) {
      $form_state->setErrorByName($name$message);
    }
  }

  /** * Get any database errors and links them to a form element. * * @param array $database * An array of database settings. * @param string $settings_file * The settings file that contains the database settings. * * @return array * An array of form errors keyed by the element name and parents. */
Home | Imprint | This part of the site doesn't use cookies.