2 namespace Civi\Afform\Event
;
4 use Civi\Afform\FormDataModel
;
5 use Civi\Api4\Action\Afform\Submit
;
8 * Class AfformSubmitEvent
9 * @package Civi\Afform\Event
11 * Handle submission of an "<af-form>".
12 * Listeners ought to take any recognized items from `entityValues`, handle
13 * them, and remove them.
15 * NOTE: I'm on the fence about whether to expose the arrays or more targeted
16 * methods. For the moment, this is only expected to be used internally,
19 class AfformSubmitEvent
extends AfformBaseEvent
{
23 * List of definitions of the entities.
24 * $entityDefns['spouse'] = ['type' => 'Individual'];
30 * List of submitted entities to save.
31 * $entityValues['Contact']['spouse'] = ['first_name' => 'Optimus Prime'];
36 * AfformSubmitEvent constructor.
38 * @param array $afform
39 * @param \Civi\Afform\FormDataModel $formDataModel
40 * @param \Civi\Api4\Action\Afform\Submit $apiRequest
41 * @param array $entityDefns
42 * @param array $entityValues
44 public function __construct(array $afform, FormDataModel
$formDataModel, Submit
$apiRequest, $entityDefns, array $entityValues) {
45 parent
::__construct($afform, $formDataModel, $apiRequest);
46 $this->entityDefns
= $entityDefns;
47 $this->entityValues
= $entityValues;
51 * List of entity types which need processing.
54 * Ex: ['Contact', 'Activity']
56 public function getTypes() {
57 return array_keys($this->entityValues
);