From 80ff12c29fb49238709722b103dc86c5af2b7803 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 Sep 2021 09:25:15 -0400 Subject: [PATCH] Afform - Add getters/setters to the AfformSubmitEvent class This makes it easier for 3rd-parties to interact with the event. --- .../Civi/Afform/Event/AfformSubmitEvent.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ext/afform/core/Civi/Afform/Event/AfformSubmitEvent.php b/ext/afform/core/Civi/Afform/Event/AfformSubmitEvent.php index 1277cf66db..1788763d3c 100644 --- a/ext/afform/core/Civi/Afform/Event/AfformSubmitEvent.php +++ b/ext/afform/core/Civi/Afform/Event/AfformSubmitEvent.php @@ -107,6 +107,33 @@ class AfformSubmitEvent extends AfformBaseEvent { return $this; } + /** + * Get the id of a saved record + * @param int $index + * @return mixed + */ + public function getEntityId(int $index = 0) { + $idField = CoreUtil::getIdFieldName($this->entityName); + return $this->entityIds[$this->entityName][$index][$idField] ?? NULL; + } + + /** + * Get records to be saved + * @return array + */ + public function getRecords(): array { + return $this->records; + } + + /** + * @param array $records + * @return $this + */ + public function setRecords(array $records) { + $this->records = $records; + return $this; + } + /** * @param int $index * @param string $joinEntity -- 2.25.1