(NFC) Comment noting parallel functions
authorTim Otten <totten@civicrm.org>
Mon, 8 Aug 2022 21:10:59 +0000 (14:10 -0700)
committerTim Otten <totten@civicrm.org>
Mon, 8 Aug 2022 21:21:19 +0000 (14:21 -0700)
CRM/Api4/Page/AJAX.php
CRM/Api4/Permission.php

index 4816ea9c97d9261c355bf6d2e3e9304ddc2d6d3a..0aa40e94d9cdea315bd901f0dd25d5be63ce5b68 100644 (file)
@@ -58,8 +58,9 @@ class CRM_Api4_Page_AJAX extends CRM_Core_Page {
       CRM_Utils_System::civiExit();
     }
     try {
-      // Call multiple
+      // Two call formats. Which one was used? Note: CRM_Api4_Permission::check() and CRM_Api4_Page_AJAX::run() should have matching conditionals.
       if (empty($this->urlPath[3])) {
+        // Received multi-call format
         $calls = CRM_Utils_Request::retrieve('calls', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST');
         $calls = json_decode($calls, TRUE);
         $response = [];
@@ -67,8 +68,8 @@ class CRM_Api4_Page_AJAX extends CRM_Core_Page {
           $response[$index] = call_user_func_array([$this, 'execute'], $call);
         }
       }
-      // Call single
       else {
+        // Received single-call format
         $entity = $this->urlPath[3];
         $action = $this->urlPath[4];
         $params = CRM_Utils_Request::retrieve('params', 'String');
index fa8d0ecca05d467204edc1df2459a8aecbe47404..e476627656063aa82f0b3b935cbe8ab2454bdbb2 100644 (file)
@@ -26,7 +26,9 @@ class CRM_Api4_Permission {
     $defaultPermissions = [
       ['access CiviCRM', 'access AJAX API'],
     ];
+    // Two call formats. Which one was used? Note: CRM_Api4_Permission::check() and CRM_Api4_Page_AJAX::run() should have matching conditionals.
     if (!empty($urlPath[3])) {
+      // Received single-call format
       $entity = $urlPath[3];
       $action = $urlPath[4];
       $permissions = $defaultPermissions;
@@ -34,6 +36,7 @@ class CRM_Api4_Permission {
       return CRM_Core_Permission::check($permissions);
     }
     else {
+      // Received multi-call format
       $calls = CRM_Utils_Request::retrieve('calls', 'String', CRM_Core_DAO::$_nullObject, TRUE, NULL, 'POST');
       $calls = json_decode($calls, TRUE);
       foreach ($calls as $call) {