blob: 784b45fd7a3e65e0fc4cca5ab407dd9eadb79f1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<?php
namespace Wcms;
use JamesMoss\Flywheel;
use Wcms\Flywheel\Formatter\JSON;
use Wcms\Flywheel\Query;
use Wcms\Flywheel\Repository;
class Modeldb extends Model
{
protected $database;
/** @var Repository */
protected $repo;
public function __construct()
{
$this->dbinit();
}
public function dbinit($dir = Model::DATABASE_DIR)
{
$this->database = new Flywheel\Config($dir, [
'query_class' => Query::class,
'formatter' => new JSON(),
]);
}
public function storeinit(string $repo)
{
$this->repo = new Repository($repo, $this->database);
}
/**
* List every IDs of a database
*
* @return array of ID strings
*/
public function list(): array
{
return $this->repo->getAllIds();
}
}
|