1 | <?php |
||
33 | class ODM extends Component implements ODMInterface, SingletonInterface |
||
34 | { |
||
35 | /** |
||
36 | * Memory section to store ODM schema. |
||
37 | */ |
||
38 | const MEMORY = 'odm.schema'; |
||
39 | |||
40 | /** |
||
41 | * Already created instantiators. |
||
42 | * |
||
43 | * @invisible |
||
44 | * @var InstantiatorInterface[] |
||
45 | */ |
||
46 | private $instantiators = []; |
||
47 | |||
48 | /** |
||
49 | * ODM schema. |
||
50 | * |
||
51 | * @invisible |
||
52 | * @var array |
||
53 | */ |
||
54 | private $schema = []; |
||
55 | |||
56 | /** |
||
57 | * @var MongoManager |
||
58 | */ |
||
59 | protected $manager; |
||
60 | |||
61 | /** |
||
62 | * @var LocatorInterface |
||
63 | */ |
||
64 | protected $locator; |
||
65 | |||
66 | /** |
||
67 | * @invisible |
||
68 | * @var MemoryInterface |
||
69 | */ |
||
70 | protected $memory; |
||
71 | |||
72 | /** |
||
73 | * Container defines working scope for all Documents and DocumentEntities. |
||
74 | * |
||
75 | * @var ContainerInterface |
||
76 | */ |
||
77 | protected $container; |
||
78 | |||
79 | /** |
||
80 | * @param MongoManager $manager |
||
81 | * @param LocatorInterface $locator |
||
82 | * @param MemoryInterface $memory |
||
83 | * @param ContainerInterface $container |
||
84 | */ |
||
85 | public function __construct( |
||
100 | |||
101 | /** |
||
102 | * Create instance of ORM SchemaBuilder. |
||
103 | * |
||
104 | * @param bool $locate Set to true to automatically locate available documents and document |
||
105 | * sources in a project files (based on tokenizer scope). |
||
106 | * |
||
107 | * @return SchemaBuilder |
||
108 | * |
||
109 | * @throws SchemaException |
||
110 | */ |
||
111 | public function schemaBuilder(bool $locate = true): SchemaBuilder |
||
130 | |||
131 | /** |
||
132 | * Specify behaviour schema for ODM to be used. |
||
133 | * |
||
134 | * @param SchemaBuilder $builder |
||
135 | * @param bool $remember Set to true to remember packed schema in memory. |
||
136 | */ |
||
137 | public function buildSchema(SchemaBuilder $builder, bool $remember = false) |
||
145 | |||
146 | /** |
||
147 | * {@inheritdoc} |
||
148 | */ |
||
149 | public function define(string $class, int $property) |
||
167 | |||
168 | /** |
||
169 | * Get source (selection repository) for specific entity class. |
||
170 | * |
||
171 | * @param string $class |
||
172 | * |
||
173 | * @return DocumentSource |
||
174 | */ |
||
175 | public function source(string $class): DocumentSource |
||
196 | |||
197 | /** |
||
198 | * {@inheritdoc} |
||
199 | */ |
||
200 | public function selector(string $class): DocumentSelector |
||
208 | |||
209 | /** |
||
210 | * {@inheritdoc} |
||
211 | */ |
||
212 | public function collection(string $class): Collection |
||
220 | |||
221 | /** |
||
222 | * {@inheritdoc} |
||
223 | */ |
||
224 | public function make( |
||
231 | |||
232 | /** |
||
233 | * Get object responsible for class instantiation. |
||
234 | * |
||
235 | * @param string $class |
||
236 | * |
||
237 | * @return InstantiatorInterface |
||
238 | */ |
||
239 | protected function instantiator(string $class): InstantiatorInterface |
||
258 | |||
259 | /** |
||
260 | * Load packed schema from memory. |
||
261 | * |
||
262 | * @return array |
||
263 | */ |
||
264 | protected function loadSchema(): array |
||
268 | |||
269 | /** |
||
270 | * Get ODM specific factory. |
||
271 | * |
||
272 | * @return FactoryInterface |
||
273 | */ |
||
274 | protected function getFactory(): FactoryInterface |
||
282 | |||
283 | /** |
||
284 | * Create valid MongoId (ObjectID now) object based on string or id provided from client side. |
||
285 | * |
||
286 | * @param mixed $mongoID String or MongoId object. |
||
287 | * |
||
288 | * @return ObjectID|null |
||
289 | */ |
||
290 | public static function mongoID($mongoID) |
||
311 | } |