Changeset View
Changeset View
Standalone View
Standalone View
src/Tasks/BootstrapSqliteRepository.php
Show All 9 Lines | class BootstrapSqliteRepository extends Task { | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
private $filename; | private $filename; | ||||
public function __construct (?string $filename = null) { | public function __construct (?string $filename = null) { | ||||
$this->filename = $filename ?? $this->getDefaultFilename(); | $this->filename = $filename ?? $this->getDefaultFilename(); | ||||
} | } | ||||
/// | |||||
/// Public methods | |||||
/// | |||||
public function run () : void { | public function run () : void { | ||||
(new SqliteRepository($this->filename))->bootstrap(); | (new SqliteRepository($this->filename))->bootstrap(); | ||||
} | } | ||||
public static function getUsage () : string { | |||||
return <<<DOC | |||||
%command% [path to site database]: creates a database with the required table | |||||
If the path is omitted, the path is extracted from the environment. | |||||
You can set the default path setting SAAS_SITES_DB environment variable. | |||||
DOC; | |||||
} | |||||
/// | |||||
/// Helper methods | |||||
/// | |||||
private function getDefaultFilename() : string { | private function getDefaultFilename() : string { | ||||
return $_ENV["SAAS_SITES_DB"]; | return getenv("SAAS_SITES_DB"); | ||||
} | } | ||||
} | } |
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator