1 | <?php |
||
60 | abstract class Document extends DocumentEntity implements ActiveEntityInterface |
||
61 | { |
||
62 | /** |
||
63 | * Associated collection and database names, by default will be resolved based on a class name. |
||
64 | */ |
||
65 | const DATABASE = null; |
||
66 | const COLLECTION = null; |
||
67 | |||
68 | /** |
||
69 | * Set of indexes to be created for associated collection. Use "@options" for additional |
||
70 | * index options. |
||
71 | * |
||
72 | * Example: |
||
73 | * const INDEXES = [ |
||
74 | * ['email' => 1, '@options' => ['unique' => true]], |
||
75 | * ['name' => 1] |
||
76 | * ]; |
||
77 | * |
||
78 | * @link http://php.net/manual/en/mongocollection.ensureindex.php |
||
79 | * @var array |
||
80 | */ |
||
81 | const INDEXES = []; |
||
82 | |||
83 | /** |
||
84 | * Documents must ALWAYS have _id field. |
||
85 | */ |
||
86 | const SCHEMA = [ |
||
87 | '_id' => ObjectID::class |
||
88 | ]; |
||
89 | |||
90 | /** |
||
91 | * _id is always nullable. |
||
92 | */ |
||
93 | const DEFAULTS = [ |
||
94 | '_id' => null |
||
95 | ]; |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function __construct(array $data = [], ODMInterface $odm = null, array $schema = null) |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function isLoaded(): bool |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function primaryKey() |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | * |
||
129 | * @event create(DocumentEvent) |
||
130 | * @event created(DocumentEvent) |
||
131 | * @event update(DocumentEvent) |
||
132 | * @event updated(DocumentEvent) |
||
133 | */ |
||
134 | public function save(): int |
||
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | * |
||
172 | * @event delete(DocumentEvent) |
||
173 | * @event deleted(DocumentEvent) |
||
174 | */ |
||
175 | public function delete() |
||
191 | } |