Skip to content
Snippets Groups Projects
Commit 388030e5 authored by totten's avatar totten
Browse files

(WIP) afform_log - Wrap "prefill" with log statement

parent 5414f0d8
Branches
Tags
No related merge requests found
......@@ -10,6 +10,52 @@ use CRM_AfformLog_ExtensionUtil as E;
*/
function afform_log_civicrm_config(&$config) {
_afform_log_civix_civicrm_config($config);
if (isset(Civi::$statics[__FUNCTION__])) {
return;
}
Civi::$statics[__FUNCTION__] = 1;
Civi::dispatcher()->addListener('civi.api.prepare', '_afform_log_wrap', Civi\API\Events::W_LATE);
}
/**
* @param \Civi\API\Event\PrepareEvent $event
*/
function _afform_log_wrap($event) {
$a = $event->getApiRequest();
switch ($a['entity'] . '.' . $a['action']) {
case 'Afform.prefill':
// $event->wrapApi('_afform_log_wrap_prefill');
break;
case 'Afform.submit':
// $event->wrapApi('_afform_log_wrap_submit');
break;
}
}
/**
* Handle the Mailing.submit API.
*
* @param \Civi\Api4\Action\Afform\Prefill $apiRequest
* The submitted API request.
* @param callable $continue
* The original/upstream implementation of Mailing.submit API.
* @return array
* @throws \API_Exception
*/
function _afform_log_wrap_prefill(\Civi\Api4\Action\Afform\Prefill $apiRequest, $continue) {
// FIXME: Get a reference to the form. Check which logging is active.
\Civi\Api4\AfformLog::create()
->setCheckPermissions(FALSE)
->addValue('name', $apiRequest->getName())
->addValue('type', 'read')
->addValue('data', [
// ...
])
->execute();
return $continue($apiRequest);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment