Afform - Delegated API calls should use a security helper
authorTim Otten <totten@civicrm.org>
Thu, 11 Feb 2021 02:25:23 +0000 (18:25 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 17 Feb 2021 09:24:25 +0000 (01:24 -0800)
commit0fd2d6af2c865a13875021fbfbc81470495d28dc
tree5754e2ab8188a6ca4921f934fa0e5e32dc164146
parentc4838b3d4231ef37f2fffca642ac36eb0a40caf2
Afform - Delegated API calls should use a security helper

Before
------

The `Prefill`, `Submit`, and `AbstractProcessor` have various calls to `civicrm_api4()`
which are meant to read/write data for a specific entity.

These calls may or may not have `checkPermissions` sprinkled in.

After
-----

Those calls to `civicrm_api4()` now go through a wrapper. For example:

```php
$formDataModel->getSecureApi4('spouse')('Contact', 'get', [...]);
```

In this call, we use the settings for the `spouse` entity to pick a security
policy.  Then, we execute the `Contact.get` API within that security policy.
ext/afform/core/Civi/Afform/FormDataModel.php
ext/afform/core/Civi/Api4/Action/Afform/AbstractProcessor.php
ext/afform/core/Civi/Api4/Action/Afform/Prefill.php
ext/afform/core/Civi/Api4/Action/Afform/Submit.php