Trigger.php 966 Bytes
Newer Older
jaapjansma's avatar
jaapjansma committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<?php
/**
 * @author Jaap Jansma <jaap.jansma@civicoop.org>
 * @license AGPL-3.0
 */

class CRM_WebformCivirules_Trigger extends CRM_Civirules_Trigger {

  /**
   * Returns an array of entities on which the trigger reacts
   *
   * @return CRM_Civirules_TriggerData_EntityDefinition
   */
  protected function reactOnEntity() {
    return new CRM_Civirules_TriggerData_EntityDefinition('webform_civirules_submission', 'webform_civirules_submission', null, 'webform_civirules_submission');
  }

  public function triggerTrigger($contact_id, $contact_num, $data, $contacts, $submission_id, $node_id) {
    $triggerData = new CRM_WebformCivirules_TriggerData($contact_id, $contact_num, $data, $contacts, $submission_id, $node_id);
    $this->alterTriggerData($triggerData);
    $triggers = CRM_Civirules_BAO_Rule::findRulesByClassname(get_class($this));
    foreach ($triggers as $trigger) {
      CRM_Civirules_Engine::triggerRule($trigger, $triggerData);
    }
  }

}