mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
More tweaks
- Changed Data::$l to Data::$lang; it's not used enough to justify the possibly confusing shortening - Made database auto-update a general rather than per-driver setting - Added settings for forthcoming feed fetching service
This commit is contained in:
parent
387b40829b
commit
ac73ed0e7f
8 changed files with 24 additions and 20 deletions
|
@ -83,7 +83,7 @@ abstract class AbstractException extends \Exception {
|
|||
$code = self::CODES[$codeID];
|
||||
$msg = "Exception.".str_replace("\\", "/", $class).".$msgID";
|
||||
}
|
||||
$msg = Data::$l->msg($msg, $vars);
|
||||
$msg = Data::$lang->msg($msg, $vars);
|
||||
}
|
||||
parent::__construct($msg, $code, $e);
|
||||
}
|
||||
|
|
10
lib/Conf.php
10
lib/Conf.php
|
@ -7,27 +7,31 @@ class Conf {
|
|||
|
||||
public $dbDriver = Db\SQLite3\Driver::class;
|
||||
public $dbSchemaBase = BASE.'sql';
|
||||
public $dbAutoUpdate = true;
|
||||
public $dbSQLite3File = BASE."arsse.db";
|
||||
public $dbSQLite3Key = "";
|
||||
public $dbSQLite3AutoUpd = true;
|
||||
public $dbPostgreSQLHost = "localhost";
|
||||
public $dbPostgreSQLUser = "arsse";
|
||||
public $dbPostgreSQLPass = "";
|
||||
public $dbPostgreSQLPort = 5432;
|
||||
public $dbPostgreSQLDb = "arsse";
|
||||
public $dbPostgreSQLSchema = "";
|
||||
public $dbPostgreSQLAutoUpd = true;
|
||||
public $dbMySQLHost = "localhost";
|
||||
public $dbMySQLUser = "arsse";
|
||||
public $dbMySQLPass = "";
|
||||
public $dbMySQLPort = 3306;
|
||||
public $dbMySQLDb = "arsse";
|
||||
public $dbMySQLAutoUpd = true;
|
||||
|
||||
public $userDriver = User\Internal\Driver::class;
|
||||
public $userComposeNames = true;
|
||||
public $userTempPasswordLength = 20;
|
||||
|
||||
public $serviceDriver = Service\Curl\Driver::class;
|
||||
public $serviceFrequency = "PT2M";
|
||||
public $serviceCurlBase = "http://localhost/";
|
||||
public $serviceCurlUser = null;
|
||||
public $serviceCurlPassword = null;
|
||||
|
||||
public $fetchTimeout = 10;
|
||||
public $fetchSizeLimit = 2 * 1024 * 1024;
|
||||
public $fetchUserAgentString;
|
||||
|
|
|
@ -3,15 +3,15 @@ declare(strict_types=1);
|
|||
namespace JKingWeb\Arsse;
|
||||
|
||||
class Data {
|
||||
public static $l;
|
||||
public static $lang;
|
||||
public static $conf;
|
||||
public static $db;
|
||||
public static $user;
|
||||
|
||||
static function load(Conf $conf) {
|
||||
static::$l = new Lang();
|
||||
static::$lang = new Lang();
|
||||
static::$conf = $conf;
|
||||
static::$l->set($conf->lang);
|
||||
static::$lang->set($conf->lang);
|
||||
static::$db = new Database();
|
||||
static::$user = new User();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
|||
}
|
||||
}
|
||||
|
||||
protected function makeConnection(string $file, int $opts, string $key): \SQLite3 {
|
||||
protected function makeConnection(string $file, int $opts, string $key) {
|
||||
return new \SQLite3($file, $opts, $key);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
|||
|
||||
|
||||
static public function driverName(): string {
|
||||
return Data::$l->msg("Driver.Db.SQLite3.Name");
|
||||
return Data::$lang->msg("Driver.Db.SQLite3.Name");
|
||||
}
|
||||
|
||||
public function schemaVersion(): int {
|
||||
|
@ -66,7 +66,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
|||
|
||||
public function schemaUpdate(int $to): bool {
|
||||
$ver = $this->schemaVersion();
|
||||
if(!Data::$conf->dbSQLite3AutoUpd) throw new Exception("updateManual", ['version' => $ver, 'driver_name' => $this->driverName()]);
|
||||
if(!Data::$conf->dbAutoUpdate) throw new Exception("updateManual", ['version' => $ver, 'driver_name' => $this->driverName()]);
|
||||
if($ver >= $to) throw new Exception("updateTooNew", ['difference' => ($ver - $to), 'current' => $ver, 'target' => $to, 'driver_name' => $this->driverName()]);
|
||||
$sep = \DIRECTORY_SEPARATOR;
|
||||
$path = Data::$conf->dbSchemaBase.$sep."SQLite3".$sep;
|
||||
|
|
|
@ -21,7 +21,7 @@ final class Driver implements Iface {
|
|||
];
|
||||
|
||||
static public function driverName(): string {
|
||||
return Data::$l->msg("Driver.User.Internal.Name");
|
||||
return Data::$lang->msg("Driver.User.Internal.Name");
|
||||
}
|
||||
|
||||
public function driverFunctions(string $function = null) {
|
||||
|
|
|
@ -8,14 +8,14 @@ class TestException extends Test\AbstractTest {
|
|||
function setUp() {
|
||||
$this->clearData(false);
|
||||
// create a mock Lang object so as not to create a dependency loop
|
||||
Data::$l = Phake::mock(Lang::class);
|
||||
Phake::when(Data::$l)->msg->thenReturn("");
|
||||
Data::$lang = Phake::mock(Lang::class);
|
||||
Phake::when(Data::$lang)->msg->thenReturn("");
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
// verify calls to the mock Lang object
|
||||
Phake::verify(Data::$l, Phake::atLeast(0))->msg($this->isType("string"), $this->anything());
|
||||
Phake::verifyNoOtherInteractions(Data::$l);
|
||||
Phake::verify(Data::$lang, Phake::atLeast(0))->msg($this->isType("string"), $this->anything());
|
||||
Phake::verifyNoOtherInteractions(Data::$lang);
|
||||
// clean up
|
||||
$this->clearData(true);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
Data::$$prop = null;
|
||||
}
|
||||
if($loadLang) {
|
||||
Data::$l = new \JKingWeb\Arsse\Lang();
|
||||
Data::$lang = new \JKingWeb\Arsse\Lang();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -37,16 +37,16 @@ trait Setup {
|
|||
$this->l = new TestLang($this->path);
|
||||
// create a mock Lang object so as not to create a dependency loop
|
||||
$this->clearData(false);
|
||||
Data::$l = Phake::mock(Lang::class);
|
||||
Phake::when(Data::$l)->msg->thenReturn("");
|
||||
Data::$lang = Phake::mock(Lang::class);
|
||||
Phake::when(Data::$lang)->msg->thenReturn("");
|
||||
// call the additional setup method if it exists
|
||||
if(method_exists($this, "setUpSeries")) $this->setUpSeries();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
// verify calls to the mock Lang object
|
||||
Phake::verify(Data::$l, Phake::atLeast(0))->msg($this->isType("string"), $this->anything());
|
||||
Phake::verifyNoOtherInteractions(Data::$l);
|
||||
Phake::verify(Data::$lang, Phake::atLeast(0))->msg($this->isType("string"), $this->anything());
|
||||
Phake::verifyNoOtherInteractions(Data::$lang);
|
||||
// clean up
|
||||
$this->clearData(true);
|
||||
// call the additional teardiwn method if it exists
|
||||
|
|
Loading…
Reference in a new issue