You are here

protected function flag_entity::invoke_rules_event in Flag 7.3

Invoke a Rules event in reaction to a flagging or unflagging.

Parameters

$action: Either 'flag' or 'unflag'.

$flagging: The flagging entity that is either newly created or about to be deleted.

$entity_id: The entity ID of entity being flagged or unflagged.

$account: The account performing the action.

Overrides flag_flag::invoke_rules_event

File

includes/flag/flag_entity.inc, line 175
Contains the flag_entity class.

Class

flag_entity
Base entity flag handler.

Code

protected function invoke_rules_event($action, $flagging, $entity_id, $account) {
  switch ($action) {
    case 'flag':
      $event_name = 'flag_flagged_' . $this->name;
      break;
    case 'unflag':
      $event_name = 'flag_unflagged_' . $this->name;
      break;
  }
  $variables = array(
    'flag' => $this,
    'flagged_' . $this->entity_type => $entity_id,
    'flagging_user' => $account,
    'flagging' => $flagging,
  );
  rules_invoke_event_by_args($event_name, $variables);
}