Tasks.php 1.8 KB
Newer Older
1
2
<?php

Crell's avatar
Crell committed
3
4
5
6
/**
 * @file
 * Definition of Drupal\Core\Database\Driver\sqlite\Install\Tasks
 */
7

8
namespace Drupal\Core\Database\Driver\sqlite\Install;
9

10
use Drupal\Core\Database\Install\Tasks as InstallTasks;
11

ayelet_Cr's avatar
ayelet_Cr committed
12
13
use SplFileInfo;

14
15
16
17
18
19
20
21
22
23
class Tasks extends InstallTasks {
  protected $pdoDriver = 'sqlite';

  public function name() {
    return st('SQLite');
  }

  /**
   * Minimum engine version.
   *
24
   * @todo Consider upping to 3.6.8 in Drupal 8 to get SAVEPOINT support.
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
   */
  public function minimumVersion() {
    return '3.3.7';
  }

  public function getFormOptions($database) {
    $form = parent::getFormOptions($database);

    // Remove the options that only apply to client/server style databases.
    unset($form['username'], $form['password'], $form['advanced_options']['host'], $form['advanced_options']['port']);

    // Make the text more accurate for SQLite.
    $form['database']['#title'] = st('Database file');
    $form['database']['#description'] = st('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name()));
    $default_database = conf_path(FALSE, TRUE) . '/files/.ht.sqlite';
    $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database'];
    return $form;
  }

  public function validateDatabaseSettings($database) {
    // Perform standard validation.
    $errors = parent::validateDatabaseSettings($database);

    // Verify the database is writable.
    $db_directory = new SplFileInfo(dirname($database['database']));
    if (!$db_directory->isWritable()) {
      $errors[$database['driver'] . '][database'] = st('The directory you specified is not writable by the web server.');
    }

    return $errors;
  }
}