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

(REF) dev/core#1744 - Simplify Afform event naming #20555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ext/afform/core/Civi/Api4/Action/Afform/Submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
class Submit extends AbstractProcessor {

/**
* @deprecated - You may simply use the event name directly. dev/core#1744
*/
const EVENT_NAME = 'civi.afform.submit';

/**
Expand Down Expand Up @@ -53,7 +56,7 @@ protected function processForm() {
$records = $this->replaceReferences($entityName, $entityValues[$entityName]);
$this->fillIdFields($records, $entityName);
$event = new AfformSubmitEvent($this->_afform, $this->_formDataModel, $this, $records, $entityType, $entityName, $this->_entityIds);
\Civi::dispatcher()->dispatch(self::EVENT_NAME, $event);
\Civi::dispatcher()->dispatch('civi.afform.submit', $event);
}

// What should I return?
Expand Down
5 changes: 2 additions & 3 deletions ext/afform/core/afform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require_once 'afform.civix.php';
use CRM_Afform_ExtensionUtil as E;
use Civi\Api4\Action\Afform\Submit;

/**
* Filter the content of $params to only have supported afform fields.
Expand Down Expand Up @@ -50,8 +49,8 @@ function afform_civicrm_config(&$config) {
Civi::$statics[__FUNCTION__] = 1;

$dispatcher = Civi::dispatcher();
$dispatcher->addListener(Submit::EVENT_NAME, [Submit::class, 'processGenericEntity'], 0);
$dispatcher->addListener(Submit::EVENT_NAME, [Submit::class, 'preprocessContact'], 10);
$dispatcher->addListener('civi.afform.submit', ['\Civi\Api4\Action\Afform\Submit', 'processGenericEntity'], 0);
$dispatcher->addListener('civi.afform.submit', ['\Civi\Api4\Action\Afform\Submit', 'preprocessContact'], 10);
$dispatcher->addListener('hook_civicrm_angularModules', ['\Civi\Afform\AngularDependencyMapper', 'autoReq'], -1000);
$dispatcher->addListener('hook_civicrm_alterAngular', ['\Civi\Afform\AfformMetadataInjector', 'preprocess']);
$dispatcher->addListener('hook_civicrm_check', ['\Civi\Afform\StatusChecks', 'hook_civicrm_check']);
Expand Down