1 | <?php |
||
18 | abstract class AbstractZohoDao |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * The class implementing API methods not directly related to a specific module. |
||
23 | * |
||
24 | * @var ZohoClient |
||
25 | */ |
||
26 | protected $zohoClient; |
||
27 | |||
28 | /** |
||
29 | * Wether or not to log Zoho Api Reponses |
||
30 | * |
||
31 | * @var bool |
||
32 | */ |
||
33 | protected $logResponses = false; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * Array that contains fields that can't be managed |
||
38 | * with the ORM and are manually added with the |
||
39 | * addUnmanagedField method |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $unmanagedFields = []; |
||
43 | |||
44 | public function __construct(ZohoClient $zohoClient) |
||
48 | |||
49 | abstract public function getModule(); |
||
54 | |||
55 | /** |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function isLogResponses(): bool { |
||
61 | |||
62 | /** |
||
63 | * @param bool $logResponses |
||
64 | */ |
||
65 | public function setLogResponses( bool $logResponses ): void { |
||
68 | |||
69 | /** |
||
70 | * @return ZohoClient |
||
71 | */ |
||
72 | public function getZohoClient(): ZohoClient |
||
76 | |||
77 | |||
78 | /** |
||
79 | * @return Field[] |
||
80 | */ |
||
81 | public function getFields() |
||
89 | |||
90 | |||
91 | /** |
||
92 | * Returns a module from Zoho. |
||
93 | * |
||
94 | * @return ZCRMModule |
||
95 | */ |
||
96 | public function getZCRMModule() |
||
100 | |||
101 | /** |
||
102 | * Parse a Zoho Response in order to retrieve one or several ZohoBeans from it. |
||
103 | * |
||
104 | * @param ZCRMRecord[] $ZCRMRecords |
||
105 | * @return ZohoBeanInterface[] The array of Zoho Beans parsed from the response |
||
106 | * @throws ZohoCRMORMException |
||
107 | */ |
||
108 | public function getBeansFromZCRMRecords(array $ZCRMRecords) |
||
125 | |||
126 | /** |
||
127 | * Implements deleteRecords API method. |
||
128 | * |
||
129 | * @param string $id |
||
130 | * @return ZohoBeanInterface[] |
||
131 | * @throws ZohoCRMORMException |
||
132 | */ |
||
133 | public function delete($id): array |
||
148 | |||
149 | /** |
||
150 | * Implements getRecordById API method. |
||
151 | * |
||
152 | * @param string $id Zoho Id of the record to retrieve OR an array of IDs |
||
153 | * |
||
154 | * @return ZohoBeanInterface The array of Zoho Beans parsed from the response |
||
155 | * @throws ZohoCRMORMException |
||
156 | */ |
||
157 | public function getById($id): ZohoBeanInterface |
||
165 | |||
166 | /** |
||
167 | * Implements getRecords API method. |
||
168 | * |
||
169 | * @param string|null $cvId |
||
170 | * @param string|null $sortColumnString |
||
171 | * @param string|null $sortOrderString |
||
172 | * @param \DateTime|null $lastModifiedTime |
||
173 | * @param int $page |
||
174 | * @param int $perPage |
||
175 | * @return ZohoBeanInterface[] |
||
176 | * @throws ZohoCRMORMException |
||
177 | * @throws \ZCRMException |
||
178 | */ |
||
179 | public function getRecords($cvId = null, $sortColumnString = null, $sortOrderString = null, \DateTime $lastModifiedTime = null, $page = 1, $perPage = 200): array |
||
194 | |||
195 | /** |
||
196 | * Returns the list of deleted records. |
||
197 | * |
||
198 | * @param \DateTimeInterface|null $lastModifiedTime |
||
199 | * @param int $page |
||
200 | * @param int $perPage |
||
201 | * @return \ZCRMTrashRecord[] |
||
202 | * @throws \ZCRMException |
||
203 | */ |
||
204 | public function getDeletedRecordIds(\DateTimeInterface $lastModifiedTime = null, $page = 1, $perPage = 200) |
||
208 | |||
209 | /** |
||
210 | * @Todo |
||
211 | */ |
||
212 | // public function getRelatedRecords |
||
213 | // public function searchRecords |
||
214 | // public function uploadFile |
||
215 | // public function downloadFile |
||
216 | |||
217 | /** |
||
218 | * Implements insertRecords or updateRecords or upsertRecords API method. |
||
219 | * |
||
220 | * @param ZohoBeanInterface[] $beans |
||
221 | * @param bool $wfTrigger Whether or not the call should |
||
222 | * trigger the workflows related to a |
||
223 | * "created" event |
||
224 | * @param string $action |
||
225 | * |
||
226 | * @return array |
||
227 | * @throws \Wabel\Zoho\CRM\Exceptions\ZohoCRMORMException |
||
228 | * @throws \zcrmsdk\crm\exception\ZCRMException |
||
229 | */ |
||
230 | public function createOrUpdate( array $beans, bool $wfTrigger = false, $action = 'upsert'): array |
||
283 | |||
284 | /** |
||
285 | * Implements insertRecords API method. |
||
286 | * |
||
287 | * @param ZohoBeanInterface[] $beans |
||
288 | * @param bool $wfTrigger Whether or not the call should |
||
289 | * trigger the workflows related to a |
||
290 | * "created" event |
||
291 | * |
||
292 | * @return array |
||
293 | * @throws ZohoCRMORMException |
||
294 | * @throws \zcrmsdk\crm\exception\ZCRMException |
||
295 | */ |
||
296 | public function insertRecords( array $beans, bool $wfTrigger = false): array |
||
300 | |||
301 | /** |
||
302 | * Implements updateRecords API method. |
||
303 | * |
||
304 | * @param ZohoBeanInterface[] $beans |
||
305 | * @param bool $wfTrigger |
||
306 | * |
||
307 | * @return array |
||
308 | * @throws ZohoCRMORMException |
||
309 | * @throws \zcrmsdk\crm\exception\ZCRMException |
||
310 | */ |
||
311 | public function updateRecords(array $beans, bool $wfTrigger = false): array |
||
315 | |||
316 | /** |
||
317 | * Saves the bean or array of beans passed in Zoho. |
||
318 | * It will perform an insert if the bean has no ZohoID or an update if the |
||
319 | * bean has a ZohoID. wfTrigger only usable for a single record |
||
320 | * update/insert. |
||
321 | * |
||
322 | * @param ZohoBeanInterface|ZohoBeanInterface[] $beans A bean or an array |
||
323 | * of beans. |
||
324 | * @param bool $wfTrigger |
||
325 | * |
||
326 | * @return array |
||
327 | * @throws ZohoCRMORMException |
||
328 | * @throws \zcrmsdk\crm\exception\ZCRMException |
||
329 | */ |
||
330 | public function save( $beans, $wfTrigger = false ): array |
||
359 | |||
360 | /** |
||
361 | * @return ZohoBeanInterface |
||
362 | * @throws ZohoCRMORMException |
||
363 | */ |
||
364 | public function create() |
||
372 | |||
373 | /** |
||
374 | * @param $fieldName |
||
375 | * @return null|Field |
||
376 | */ |
||
377 | public function getFieldFromFieldName($fieldName) |
||
393 | |||
394 | |||
395 | /** |
||
396 | * Add a field that can't be managed with the ORM |
||
397 | * |
||
398 | * @param $fieldApiName |
||
399 | * @param $value |
||
400 | */ |
||
401 | public function addUnmanagedField($fieldApiName, $value) { |
||
404 | |||
405 | /** |
||
406 | * @return array |
||
407 | */ |
||
408 | public function getUnamanagedFields() { |
||
411 | } |
||
412 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: