1 | <?php |
||
14 | class ORMContext |
||
|
|||
15 | { |
||
16 | |||
17 | private static $instance; |
||
18 | private $cache; |
||
19 | private $modelFactory; |
||
20 | private $modelValidatorFactory; |
||
21 | private $driverAdapterFactory; |
||
22 | |||
23 | 36 | private function __construct(ModelFactoryInterface $modelFactory, DriverAdapterFactoryInterface $driverAdapterFactory, ValidatorFactoryInterface $modelValidatorFactory, Cache $cache) |
|
24 | { |
||
25 | 36 | $this->modelFactory = $modelFactory; |
|
26 | 36 | $this->cache = $cache; |
|
27 | 36 | $this->driverAdapterFactory = $driverAdapterFactory; |
|
28 | 36 | $this->modelValidatorFactory = $modelValidatorFactory; |
|
29 | 36 | } |
|
30 | |||
31 | 36 | public static function initialize(ModelFactoryInterface $modelFactory, DriverAdapterFactoryInterface $driverAdapterFactory, ValidatorFactoryInterface $modelValidatorFactory, Cache $cache): ORMContext |
|
32 | { |
||
33 | 36 | self::$instance = new self($modelFactory, $driverAdapterFactory, $modelValidatorFactory, $cache); |
|
34 | 36 | return self::$instance; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * A helper for loading a method described as a string. |
||
39 | * @param string $path Model name as string |
||
40 | * @return \nibii\RecordWrapper |
||
41 | * @throws NibiiException |
||
42 | */ |
||
43 | 6 | public function load($path) |
|
52 | |||
53 | /** |
||
54 | * @param RecordWrapper $instance |
||
55 | */ |
||
56 | 36 | public function getModelTable($instance) |
|
60 | |||
61 | 36 | public function getDriverAdapter() |
|
65 | |||
66 | /** |
||
67 | * @param string $class |
||
68 | */ |
||
69 | 28 | public function getModelName($class) |
|
73 | |||
74 | 36 | public static function getInstance() : ORMContext |
|
81 | |||
82 | 28 | public function getCache() |
|
86 | |||
87 | public function getConfig() |
||
91 | |||
92 | 28 | public function getModelDescription($model) : ModelDescription |
|
96 | |||
97 | 10 | public function getModelValidatorFactory() : ValidatorFactoryInterface |
|
101 | |||
102 | 12 | public function getModelFactory() : ModelFactoryInterface |
|
106 | |||
107 | /** |
||
108 | * |
||
109 | * @return \ntentan\atiaa\DbContext |
||
110 | */ |
||
111 | 36 | public function getDbContext() |
|
115 | |||
116 | public function __destruct() |
||
120 | |||
121 | } |
||
122 |