Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Afform - Add getters/setters to the AfformSubmitEvent class #21572

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

colemanw
Copy link
Member

Overview

Adds some missing getter/setter functions to make it easier for 3rd-parties to interact with Afform submissions.

Before

Saved ids not accessible, not clear how to read or write the list of records to be saved.

After

Better

@civibot civibot bot added the master label Sep 22, 2021
@civibot
Copy link

civibot bot commented Sep 22, 2021

(Standard links)

@wyde22
Copy link
Contributor

wyde22 commented Sep 22, 2021

Thanks so lot for this patch @colemanw . I'm realizing a test and I had to review a little your code. In my project, i can't use this method getEntityId(int $index = 0). In my phpstorm IDE i have an error in the method CoreUtil (class undefined).

so i change this code for my test :

public function getEntityId(int $index = 0) { //$idField = CoreUtil::getIdFieldName($this->entityName); return $this->entityIds[$this->entityName][$index]; }

My version of civicrm is 5.40.2

This makes it easier for 3rd-parties to interact with the event.
@colemanw
Copy link
Member Author

My version of civicrm is 5.40.2

Ah, right, you would need the current beta version of CiviCRM for that to work. It was added here: 12e4505

For now, I suggest you use this (which is different from what you pasted above because it will return the id not an array). This will be compatible with this PR when you do upgrade:

  public function getEntityId(int $index = 0) {
    $idField = 'id';
    return $this->entityIds[$this->entityName][$index][$idField] ?? NULL;
  }

@wyde22
Copy link
Contributor

wyde22 commented Sep 22, 2021

Thanks @colemanw

@seamuslee001
Copy link
Contributor

This seems fine to me

@seamuslee001 seamuslee001 merged commit 29d2163 into civicrm:master Sep 22, 2021
@seamuslee001 seamuslee001 deleted the afformEvents branch September 22, 2021 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants