1 | <?php |
||
36 | abstract class DocumentEntity extends SchematicEntity implements CompositableInterface |
||
37 | { |
||
38 | use SaturateTrait; |
||
39 | |||
40 | /** |
||
41 | * Set of schema sections needed to describe entity behaviour. |
||
42 | */ |
||
43 | const SH_INSTANTIATION = 0; |
||
44 | const SH_DEFAULTS = 1; |
||
45 | const SH_AGGREGATIONS = 6; |
||
46 | const SH_COMPOSITIONS = 7; |
||
47 | |||
48 | /** |
||
49 | * Class responsible for instance construction. |
||
50 | */ |
||
51 | const INSTANTIATOR = DocumentInstantiator::class; |
||
52 | |||
53 | /** |
||
54 | * Document fields, accessors and relations. ODM will generate setters and getters for some |
||
55 | * fields based on their types. |
||
56 | * |
||
57 | * Example, fields: |
||
58 | * const SCHEMA = [ |
||
59 | * '_id' => 'MongoId', //Primary key field |
||
60 | * 'value' => 'string', //Default string field |
||
61 | * 'values' => ['string'] //ScalarArray accessor will be applied for fields like that |
||
62 | * ]; |
||
63 | * |
||
64 | * Compositions: |
||
65 | * const SCHEMA = [ |
||
66 | * ..., |
||
67 | * 'child' => Child::class, //One document are composited, for example user Profile |
||
68 | * 'many' => [Child::class] //Compositor accessor will be applied, allows to |
||
69 | * //composite many document instances |
||
70 | * ]; |
||
71 | * |
||
72 | * Documents can extend each other, in this case schema will also be inherited. |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | const SCHEMA = []; |
||
77 | |||
78 | /** |
||
79 | * Default field values. |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | const DEFAULTS = []; |
||
84 | |||
85 | /** |
||
86 | * Model behaviour configurations. |
||
87 | */ |
||
88 | const SECURED = '*'; |
||
89 | const HIDDEN = []; |
||
90 | const FILLABLE = []; |
||
91 | const SETTERS = []; |
||
92 | const GETTERS = []; |
||
93 | const ACCESSORS = []; |
||
94 | |||
95 | /** |
||
96 | * Parent ODM instance, responsible for aggregations and lazy loading operations. |
||
97 | * |
||
98 | * @invisible |
||
99 | * @var ODMInterface |
||
100 | */ |
||
101 | protected $odm; |
||
102 | |||
103 | /** |
||
104 | * Document behaviour schema. |
||
105 | * |
||
106 | * @var array |
||
107 | */ |
||
108 | private $schema = []; |
||
|
|||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | * |
||
113 | * @param ODMInterface $odm To lazy create nested document ang aggregations. |
||
114 | * |
||
115 | * @throws ScopeException When no ODM instance can be resolved. |
||
116 | */ |
||
117 | public function __construct($fields, array $schema = null, ODMInterface $odm = null) |
||
136 | |||
137 | public function withODM() |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function hasUpdates(): bool |
||
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | public function buildAtomics(string $container = ''): array |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function flushUpdates() |
||
165 | |||
166 | /** |
||
167 | * @return array |
||
168 | */ |
||
169 | public function __debugInfo() |
||
176 | |||
177 | /** |
||
178 | * {@inheritdoc} |
||
179 | */ |
||
180 | protected function iocContainer() |
||
189 | } |