aboutsummaryrefslogtreecommitdiff
path: root/app/class/Modeldb.php
blob: 92f0d22f514731b30af3befc302f580d05bb62ca (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);
	}

	public function list()
	{
		return $this->repo->getAllIds();
	}





}