Skip to content

Commit

Permalink
Merge pull request #20555 from ahed-compucorp/dev/core#1744-afform
Browse files Browse the repository at this point in the history
(REF) dev/core#1744 - Simplify Afform event naming
  • Loading branch information
eileenmcnaughton authored Jun 8, 2021
2 parents 464eb99 + 07a1bc4 commit 25b95f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit 25b95f1

Please sign in to comment.