databaseDriver() public method

public databaseDriver ( string $subtype, string $name, string $driver, string $parameter = null ) : Response
$subtype string
$name string
$driver string
$parameter string
return Symfony\Component\HttpFoundation\Response
Example #1
0
 protected function doDatabaseSqliteCheck(Controller\Exception $exceptionController, array $dbConfig)
 {
     if (extension_loaded('pdo_sqlite') === false) {
         return $exceptionController->databaseDriver('missing', 'SQLite', 'pdo_sqlite');
     }
     // If in-memory connection, skip path checks
     if (isset($dbConfig['memory']) && $dbConfig['memory'] === true) {
         return null;
     }
     $fs = new Filesystem();
     $file = $dbConfig['path'];
     // If the file is present, make sure it is writable
     if ($fs->exists($file)) {
         try {
             $fs->touch($file);
         } catch (IOException $e) {
             return $exceptionController->databasePath('file', $file, 'is not writable');
         }
         return null;
     }
     // If the file isn't present, make sure the directory
     // exists and is writable so the file can be created
     $dir = dirname($file);
     if (!$fs->exists($dir)) {
         // At this point, it is possible that the site has been moved and
         // the configured Sqlite database file path is no longer relevant
         // to the site's root path
         $cacheJson = $this->resourceManager->getPath('cache/config-cache.json');
         if ($fs->exists($cacheJson)) {
             $fs->remove($cacheJson);
             $this->config->initialize();
             if (!$fs->exists($dir)) {
                 return $exceptionController->databasePath('folder', $dir, 'does not exist');
             }
         } else {
             return $exceptionController->databasePath('folder', $dir, 'does not exist');
         }
     }
     try {
         $fs->touch($dir);
     } catch (IOException $e) {
         return $exceptionController->databasePath('folder', $dir, 'is not writable');
     }
     return null;
 }