1 | <?php |
||
24 | class ODM extends Component implements ODMInterface, SingletonInterface |
||
25 | { |
||
26 | /** |
||
27 | * Memory section to store ODM schema. |
||
28 | */ |
||
29 | const MEMORY = 'odm.schema'; |
||
30 | |||
31 | /** |
||
32 | * Already created instantiators. |
||
33 | * |
||
34 | * @invisible |
||
35 | * @var InstantiatorInterface[] |
||
36 | */ |
||
37 | private $instantiators = []; |
||
38 | |||
39 | /** |
||
40 | * ODM schema. |
||
41 | * |
||
42 | * @invisible |
||
43 | * @var array |
||
44 | */ |
||
45 | private $schema = []; |
||
46 | |||
47 | /** |
||
48 | * @var MongoManager |
||
49 | */ |
||
50 | protected $manager; |
||
51 | |||
52 | /** |
||
53 | * @var SchemaLocator |
||
54 | */ |
||
55 | protected $locator; |
||
56 | |||
57 | /** |
||
58 | * @invisible |
||
59 | * @var MemoryInterface |
||
60 | */ |
||
61 | protected $memory; |
||
62 | |||
63 | /** |
||
64 | * @var FactoryInterface |
||
65 | */ |
||
66 | protected $factory; |
||
67 | |||
68 | /** |
||
69 | * ODM constructor. |
||
70 | * |
||
71 | * @param MongoManager $manager |
||
72 | * @param SchemaLocator $locator |
||
73 | * @param MemoryInterface $memory |
||
74 | * @param FactoryInterface $factory |
||
75 | */ |
||
76 | public function __construct( |
||
91 | |||
92 | /** |
||
93 | * Update ODM schema with automatic indexations. |
||
94 | * |
||
95 | * @param bool $locate Set to true to automatically locate available documents in a project |
||
96 | * (based on tokenizer scope). |
||
97 | * |
||
98 | * @return SchemaBuilder |
||
99 | */ |
||
100 | public function schemaBuilder(bool $locate = true): SchemaBuilder |
||
112 | |||
113 | /** |
||
114 | * Specify behaviour schema for ODM to be used. |
||
115 | * |
||
116 | * @param SchemaBuilder $builder |
||
117 | * @param bool $remember Set to true to remember packed schema in memory. |
||
118 | */ |
||
119 | public function setSchema(SchemaBuilder $builder, bool $remember = false) |
||
127 | |||
128 | /** |
||
129 | * Get property from cached schema. Attention, ODM will automatically load schema if it's empty. |
||
130 | * |
||
131 | * Example: |
||
132 | * $odm->getSchema(User::class, ODM::D_INSTANTIATOR); |
||
133 | * |
||
134 | * @param string $class |
||
135 | * @param int $property See ODM constants. |
||
136 | * |
||
137 | * @return mixed |
||
138 | * |
||
139 | * @throws ODMException |
||
140 | */ |
||
141 | public function schema(string $class, int $property) |
||
159 | |||
160 | //--- |
||
161 | |||
162 | public function source(string $class): DocumentSource |
||
166 | |||
167 | |||
168 | /** |
||
169 | * Get DocumentSelector for a given class. Attention, due model inheritance selector WILL be |
||
170 | * associated with parent class. |
||
171 | * |
||
172 | * Example: |
||
173 | * Admin extends User |
||
174 | * $odm->selector(Admin::class)->getClass() == User::class |
||
175 | * |
||
176 | * @param string $class |
||
177 | * |
||
178 | * @return DocumentSelector |
||
179 | */ |
||
180 | public function selector(string $class): DocumentSelector |
||
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | public function collection(string $class): Collection |
||
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | */ |
||
204 | public function instantiate(string $class, $fields = []): CompositableInterface |
||
208 | |||
209 | /** |
||
210 | * Get object responsible for class instantiation. |
||
211 | * |
||
212 | * @param string $class |
||
213 | * |
||
214 | * @return InstantiatorInterface |
||
215 | */ |
||
216 | protected function instantiator(string $class): InstantiatorInterface |
||
232 | |||
233 | /** |
||
234 | * Load packed schema from memory. |
||
235 | * |
||
236 | * @return array |
||
237 | */ |
||
238 | protected function loadSchema(): array |
||
242 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.