ManagerInterface.php
6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
namespace Phalcon\Mvc\Model {
/**
* Phalcon\Mvc\Model\ManagerInterface initializer
*/
interface ManagerInterface {
/**
* Initializes a model in the model manager
*
* @param \Phalcon\Mvc\ModelInterface $model
*/
public function initialize($model);
/**
* Check of a model is already initialized
*
* @param string $modelName
* @return boolean
*/
public function isInitialized($modelName);
/**
* Get last initialized model
*
* @return \Phalcon\Mvc\ModelInterface
*/
public function getLastInitialized();
/**
* Loads a model throwing an exception if it doesn't exist
*
* @param string $modelName
* @param boolean $newInstance
* @return \Phalcon\Mvc\ModelInterface
*/
public function load($modelName, $newInstance);
/**
* Setup a 1-1 relation between two models
*
* @param \Phalcon\Mvc\ModelInterface $model
* @param mixed $fields
* @param string $referencedModel
* @param mixed $referencedFields
* @param array $options
* @return \Phalcon\Mvc\Model\RelationInterface
*/
public function addHasOne($model, $fields, $referencedModel, $referencedFields, $options=null);
/**
* Setup a relation reverse 1-1 between two models
*
* @param Phalcon\Mvc\ModelInterface $model
* @param mixed $fields
* @param string $referencedModel
* @param mixed $referencedFields
* @param array $options
* @return Phalcon\Mvc\Model\RelationInterface
*/
public function addBelongsTo($model, $fields, $referencedModel, $referencedFields, $options=null);
/**
* Setup a relation 1-n between two models
*
* @param Phalcon\Mvc\ModelInterface $model
* @param mixed $fields
* @param string $referencedModel
* @param mixed $referencedFields
* @param array $options
* @return Phalcon\Mvc\Model\RelationInterface
*/
public function addHasMany($model, $fields, $referencedModel, $referencedFields, $options=null);
/**
* Checks whether a model has a belongsTo relation with another model
*
* @param string $modelName
* @param string $modelRelation
* @return boolean
*/
public function existsBelongsTo($modelName, $modelRelation);
/**
* Checks whether a model has a hasMany relation with another model
*
* @param string $modelName
* @param string $modelRelation
* @return boolean
*/
public function existsHasMany($modelName, $modelRelation);
/**
* Checks whether a model has a hasOne relation with another model
*
* @param string $modelName
* @param string $modelRelation
* @return boolean
*/
public function existsHasOne($modelName, $modelRelation);
/**
* Gets belongsTo related records from a model
*
* @param string $method
* @param string $modelName
* @param string $modelRelation
* @param \Phalcon\Mvc\Model $record
* @param array $parameters
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public function getBelongsToRecords($method, $modelName, $modelRelation, $record, $parameters=null);
/**
* Gets hasMany related records from a model
*
* @param string $method
* @param string $modelName
* @param string $modelRelation
* @param \Phalcon\Mvc\Model $record
* @param array $parameters
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public function getHasManyRecords($method, $modelName, $modelRelation, $record, $parameters=null);
/**
* Gets belongsTo related records from a model
*
* @param string $method
* @param string $modelName
* @param string $modelRelation
* @param \Phalcon\Mvc\Model $record
* @param array $parameters
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public function getHasOneRecords($method, $modelName, $modelRelation, $record, $parameters=null);
/**
* Gets belongsTo relations defined on a model
*
* @param \Phalcon\Mvc\ModelInterface $model
* @return array
*/
public function getBelongsTo($model);
/**
* Gets hasMany relations defined on a model
*
* @param \Phalcon\Mvc\ModelInterface $model
* @return array
*/
public function getHasMany($model);
/**
* Gets hasOne relations defined on a model
*
* @param \Phalcon\Mvc\ModelInterface $model
* @return array
*/
public function getHasOne($model);
/**
* Gets hasOne relations defined on a model
*
* @param \Phalcon\Mvc\ModelInterface $model
* @return array
*/
public function getHasOneAndHasMany($model);
/**
* Query all the relationships defined on a model
*
* @param string $modelName
* @return \Phalcon\Mvc\Model\RelationInterface[]
*/
public function getRelations($modelName);
/**
* Query the relations between two models
*
* @param string $first
* @param string $second
* @return array
*/
public function getRelationsBetween($first, $second);
/**
* Creates a \Phalcon\Mvc\Model\Query without execute it
*
* @param string $phql
* @return \Phalcon\Mvc\Model\QueryInterface
*/
public function createQuery($phql);
/**
* Creates a \Phalcon\Mvc\Model\Query and execute it
*
* @param string $phql
* @param array $placeholders
* @return \Phalcon\Mvc\Model\QueryInterface
*/
public function executeQuery($phql, $placeholders=null);
/**
* Creates a \Phalcon\Mvc\Model\Query\Builder
*
* @param string $params
* @return \Phalcon\Mvc\Model\Query\BuilderInterface
*/
public function createBuilder($params=null);
/**
* Binds a behavior to a model
*
* @param \Phalcon\Mvc\ModelInterface $model
* @param \Phalcon\Mvc\Model\BehaviorInterface $behavior
*/
public function addBehavior($model, $behavior);
/**
* Receives events generated in the models and dispatches them to a events-manager if available
* Notify the behaviors that are listening in the model
*
* @param string $eventName
* @param \Phalcon\Mvc\ModelInterface $model
*/
public function notifyEvent($eventName, $model);
/**
* Dispatch a event to the listeners and behaviors
* This method expects that the endpoint listeners/behaviors returns true
* meaning that a least one is implemented
*
* @param \Phalcon\Mvc\ModelInterface $model
* @param string $eventName
* @param array $data
* @return boolean
*/
public function missingMethod($model, $eventName, $data);
/**
* Returns the last query created or executed in the
*
* @return \Phalcon\Mvc\Model\QueryInterface
*/
public function getLastQuery();
}
}