@@ -34,7 +34,8 @@ class FileMakerLayout
3434 * @param string $layout
3535 * @ignore
3636 */
37- public function __construct (CommunicationProvider |null $ restAPI , string $ layout )
37+ public function __construct (CommunicationProvider |null $ restAPI ,
38+ string $ layout )
3839 {
3940 $ this ->restAPI = $ restAPI ;
4041 $ this ->layout = $ layout ;
@@ -69,7 +70,9 @@ public function endCommunication(): void
6970 * @return array
7071 * @ignore
7172 */
72- private function buildPortalParameters (array |null $ param , bool |string $ shortKey = false , string $ method = "GET " ): array
73+ private function buildPortalParameters (array |null $ param ,
74+ bool |string $ shortKey = false ,
75+ string $ method = "GET " ): array
7376 {
7477 $ key = $ shortKey ? "portal " : "portalData " ;
7578 $ prefix = $ method === "GET " ? "" : "_ " ;
@@ -168,8 +171,12 @@ private function buildScriptParameters(array|null $param): array
168171 * @return FileMakerRelation|null Query result.
169172 * @throws Exception In case of any error, an exception arises.
170173 */
171- public function query (array |null $ condition = null , array |null $ sort = null , int $ offset = 0 ,
172- int $ range = 0 , array |null $ portal = null , array |null $ script = null ): FileMakerRelation |null
174+ public function query (array |null $ condition = null ,
175+ array |null $ sort = null ,
176+ int $ offset = 0 ,
177+ int $ range = 0 ,
178+ array |null $ portal = null ,
179+ array |null $ script = null ): FileMakerRelation |null
173180 {
174181 if ($ this ->restAPI ->login ()) {
175182 $ headers = ["Content-Type " => "application/json " ];
@@ -217,14 +224,19 @@ public function query(array|null $condition = null, array|null $sort = null, int
217224
218225 /**
219226 * Query to the FileMaker Database with recordId special field and returns the result as FileMakerRelation object.
220- * @param int $recordId The recordId.
227+ * @param int|null $recordId The recordId.
221228 * @param array|null $portal See the query() method's same parameter.
222229 * @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
223230 * @return FileMakerRelation|null Query result.
224231 * @throws Exception In case of any error, an exception arises.
225232 */
226- public function getRecord (int $ recordId , array |null $ portal = null , array |null $ script = null ): FileMakerRelation |null
233+ public function getRecord (int |null $ recordId ,
234+ array |null $ portal = null ,
235+ array |null $ script = null ): FileMakerRelation |null
227236 {
237+ if (is_null ($ recordId )) {
238+ return null ;
239+ }
228240 if ($ this ->restAPI ->login ()) {
229241 $ request = [];
230242 if (!is_null ($ portal )) {
@@ -266,7 +278,9 @@ public function getRecord(int $recordId, array|null $portal = null, array|null $
266278 * If the returned value is an integer larger than 0, it shows one record was created.
267279 * @throws Exception In case of any error, an exception arises.
268280 */
269- public function create (array |null $ data = null , array |null $ portal = null , array |null $ script = null ): int |null
281+ public function create (array |null $ data = null ,
282+ array |null $ portal = null ,
283+ array |null $ script = null ): int |null
270284 {
271285 if ($ this ->restAPI ->login ()) {
272286 $ headers = ["Content-Type " => "application/json " ];
@@ -290,12 +304,16 @@ public function create(array|null $data = null, array|null $portal = null, array
290304
291305 /**
292306 * Duplicate the record.
293- * @param int $recordId The valid recordId value to duplicate.
307+ * @param int|nulll $recordId The valid recordId value to duplicate.
294308 * @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
295309 * @throws Exception In case of any error, an exception arises.
296310 */
297- public function duplicate (int $ recordId , array |null $ script = null ): void
311+ public function duplicate (int |null $ recordId ,
312+ array |null $ script = null ): void
298313 {
314+ if (is_null ($ recordId )) {
315+ return ;
316+ }
299317 if ($ this ->restAPI ->login ()) {
300318 $ request = "{} " ; //FileMaker expects an empty object, so we have to set "{}" here
301319 $ headers = ["Content-Type " => "application/json " ];
@@ -311,12 +329,16 @@ public function duplicate(int $recordId, array|null $script = null): void
311329
312330 /**
313331 * Delete the record.
314- * @param int $recordId The valid recordId value to delete.
332+ * @param int|null $recordId The valid recordId value to delete.
315333 * @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
316334 * @throws Exception In case of any error, an exception arises.
317335 */
318- public function delete (int $ recordId , array |null $ script = null ): void
336+ public function delete (int |null $ recordId ,
337+ array |null $ script = null ): void
319338 {
339+ if (is_null ($ recordId )) {
340+ return ;
341+ }
320342 if ($ this ->restAPI ->login ()) {
321343 $ request = [];
322344 $ headers = null ;
@@ -332,7 +354,7 @@ public function delete(int $recordId, array|null $script = null): void
332354
333355 /**
334356 * Update fields in one record.
335- * @param int $recordId The valid recordId value to update.
357+ * @param int|null $recordId The valid recordId value to update.
336358 * @param array|null $data Associated array contains the modifying values.
337359 * Keys are field names and values is these initial values.
338360 * @param int $modId The modId to allow updating. This parameter is for detect to modifying other users.
@@ -343,9 +365,15 @@ public function delete(int $recordId, array|null $script = null): void
343365 * @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
344366 * @throws Exception In case of any error, an exception arises.
345367 */
346- public function update (int $ recordId , array |null $ data , int $ modId = -1 ,
347- array |null $ portal = null , array |null $ script = null ): void
368+ public function update (int |null $ recordId ,
369+ array |null $ data ,
370+ int $ modId = -1 ,
371+ array |null $ portal = null ,
372+ array |null $ script = null ): void
348373 {
374+ if (is_null ($ recordId )) {
375+ return ;
376+ }
349377 if ($ this ->restAPI ->login ()) {
350378 $ headers = ["Content-Type " => "application/json " ];
351379 $ params = ["layouts " => $ this ->layout , "records " => $ recordId ];
@@ -395,19 +423,25 @@ public function setGlobalField(array $fields): void
395423 /**
396424 * Upload the file into container filed.
397425 * @param string $filePath The file path to upload.
398- * @param int $recordId The Record ID of the record.
426+ * @param int|null $recordId The Record ID of the record.
399427 * @param string $containerFieldName The field name of container field.
400428 * @param int|null $containerFieldRepetition In the case of repetiton field, this has to be the number from 1.
401429 * If omitted this, the number "1" is going to be specified.
402430 * @param string|null $fileName Another file name for uploading file. If omitted, the original file name is chosen.
403431 * @throws Exception In case of any error, an exception arises.
404432 */
405- public function uploadFile (string $ filePath , int $ recordId , string $ containerFieldName ,
406- int |null $ containerFieldRepetition = null , string |null $ fileName = null ): void
433+ public function uploadFile (string $ filePath ,
434+ int |null $ recordId ,
435+ string $ containerFieldName ,
436+ int |null $ containerFieldRepetition = null ,
437+ string |null $ fileName = null ): void
407438 {
408439 if (!file_exists ($ filePath )) {
409440 throw new Exception ("File doesn't exsist: {$ filePath }. " );
410441 }
442+ if (is_null ($ recordId )) {
443+ return ;
444+ }
411445 if ($ this ->restAPI ->login ()) {
412446 $ CRLF = chr (13 ) . chr (10 );
413447 $ DQ = '" ' ;
@@ -433,13 +467,13 @@ public function uploadFile(string $filePath, int $recordId, string $containerF
433467
434468 /**
435469 * Get the metadata information of the layout. Until ver.16 this method was 'getMetadata'.
436- * @return object|null The metadata information of the layout. It has just 1 property 'metaData' the array of the field
470+ * @return object|null|bool The metadata information of the layout. It has just 1 property 'metaData' the array of the field
437471 * information is set under the 'metaData' property. There is no information about portals. Ex.:
438472 * {"metaData": [{"name": "id","type": "normal","result": "number","global": "false","repetitions": 1,"id": "1"},
439473 *{"name": "name","type": "normal","result": "text","global": "false","repetitions": 1,"id": "2"},....,]}
440474 * @throws Exception In case of any error, an exception arises.
441475 */
442- public function getMetadataOld (): object |null
476+ public function getMetadataOld (): object |null | bool
443477 {
444478 $ returnValue = false ;
445479 if ($ this ->restAPI ->login ()) {
@@ -457,7 +491,7 @@ public function getMetadataOld(): object|null
457491
458492 /**
459493 * Get metadata information of the layout.
460- * @return object|null The metadata information of the layout. It has 3 properties 'fieldMetaData', 'portalMetaData' and 'valueLists'.
494+ * @return object|null|bool The metadata information of the layout. It has 3 properties 'fieldMetaData', 'portalMetaData' and 'valueLists'.
461495 * The later one has properties having portal object name of TO name. The array of the field information is set under
462496 * 'fieldMetaData' and the portal named properties.
463497 * Ex.: {"fieldMetaData": [{"name": "id","type": "normal","displayType": "editText","result": "number","global": false,
@@ -467,7 +501,7 @@ public function getMetadataOld(): object|null
467501 * ...}...]}
468502 * @throws Exception In case of any error, an exception arises.
469503 */
470- public function getMetadata (): object |null
504+ public function getMetadata (): object |null | bool
471505 {
472506 $ returnValue = false ;
473507 if ($ this ->restAPI ->login ()) {
0 commit comments