driverRequired() public static méthode

public static driverRequired ( string | null $url = null ) : DBALException
$url string | null The URL that was provided in the connection parameters (if any).
Résultat DBALException
 /**
  * Checks the list of parameters.
  *
  * @param array $params
  */
 private static function _checkParams(array $params)
 {
     // check existance of mandatory parameters
     // driver
     if (!isset($params['driver']) && !isset($params['driverClass'])) {
         throw DBALException::driverRequired();
     }
     // check validity of parameters
     // driver
     if (isset($params['driver']) && !isset(self::$_driverMap[$params['driver']])) {
         throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
     }
     if (isset($params['driverClass']) && !in_array('Doctrine\\DBAL\\Driver', class_implements($params['driverClass'], true))) {
         throw DBALException::invalidDriverClass($params['driverClass']);
     }
 }
Exemple #2
0
 /**
  * Parses the scheme part from given connection URL and resolves the given connection parameters.
  *
  * @param array $url    The connection URL parts to evaluate.
  * @param array $params The connection parameters to resolve.
  *
  * @return array The resolved connection parameters.
  *
  * @throws DBALException if parsing failed or resolution is not possible.
  */
 private static function parseDatabaseUrlScheme(array $url, array $params)
 {
     if (isset($url['scheme'])) {
         // The requested driver from the URL scheme takes precedence
         // over the default custom driver from the connection parameters (if any).
         unset($params['driverClass']);
         // URL schemes must not contain underscores, but dashes are ok
         $driver = str_replace('-', '_', $url['scheme']);
         // The requested driver from the URL scheme takes precedence
         // over the default driver from the connection parameters (if any).
         $params['driver'] = isset(self::$driverSchemeAliases[$driver]) ? self::$driverSchemeAliases[$driver] : $driver;
         return $params;
     }
     // If a schemeless connection URL is given, we require a default driver or default custom driver
     // as connection parameter.
     if (!isset($params['driverClass']) && !isset($params['driver'])) {
         throw DBALException::driverRequired($params['url']);
     }
     return $params;
 }