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 * Values to be saved for this entity
36 * entityName e.g. Individual1, Activity1,
42 * List of Submitted Entities and their matching ids
43 * $entityIds['Individual1'] = 1;
48 * AfformSubmitEvent constructor.
50 * @param array $afform
51 * @param \Civi\Afform\FormDataModel $formDataModel
52 * @param \Civi\Api4\Action\Afform\Submit $apiRequest
53 * @param array $values
54 * @param string $entityType
55 * @param string $entityName
56 * @param array $entityIds
58 public function __construct(array $afform, FormDataModel
$formDataModel, Submit
$apiRequest, $values, string $entityType, string $entityName, array &$entityIds) {
59 parent
::__construct($afform, $formDataModel, $apiRequest);
60 $this->values
= $values;
61 $this->entityType
= $entityType;
62 $this->entityName
= $entityName;
63 $this->entityIds
= $entityIds;
67 * Set the entity type associated with this event
68 * @param string $entityType
70 public function setEntityType(string $entityType): void
{
71 $this->entityType
= $entityType;
75 * Set the values associated with this event
76 * @param array $values
78 public function setValues(array $values): void
{
79 $this->values
= $values;
83 * Set the entity name associated with this event
84 * @param string $entityName
86 public function setEntityName(string $entityName): void
{
87 $this->entityName
= $entityName;