public function applyHeraldEffects(array $effects)
 {
     assert_instances_of($effects, 'HeraldEffect');
     $result = array();
     if ($this->explicitCCs) {
         $effect = new HeraldEffect();
         $effect->setAction(HeraldActionConfig::ACTION_ADD_CC);
         $effect->setTarget(array_keys($this->explicitCCs));
         $effect->setReason('CCs provided explicitly by revision author or carried over from a ' . 'previous version of the revision.');
         $result[] = new HeraldApplyTranscript($effect, true, 'Added addresses to CC list.');
     }
     $forbidden_ccs = array_fill_keys(nonempty($this->forbiddenCCs, array()), true);
     foreach ($effects as $effect) {
         $action = $effect->getAction();
         switch ($action) {
             case HeraldActionConfig::ACTION_NOTHING:
                 $result[] = new HeraldApplyTranscript($effect, true, 'OK, did nothing.');
                 break;
             case HeraldActionConfig::ACTION_FLAG:
                 $result[] = parent::applyFlagEffect($effect, $this->revision->getPHID());
                 break;
             case HeraldActionConfig::ACTION_EMAIL:
             case HeraldActionConfig::ACTION_ADD_CC:
                 $op = $action == HeraldActionConfig::ACTION_EMAIL ? 'email' : 'CC';
                 $base_target = $effect->getTarget();
                 $forbidden = array();
                 foreach ($base_target as $key => $fbid) {
                     if (isset($forbidden_ccs[$fbid])) {
                         $forbidden[] = $fbid;
                         unset($base_target[$key]);
                     } else {
                         if ($action == HeraldActionConfig::ACTION_EMAIL) {
                             $this->emailPHIDs[$fbid] = true;
                         } else {
                             $this->newCCs[$fbid] = true;
                         }
                     }
                 }
                 if ($forbidden) {
                     $failed = clone $effect;
                     $failed->setTarget($forbidden);
                     if ($base_target) {
                         $effect->setTarget($base_target);
                         $result[] = new HeraldApplyTranscript($effect, true, 'Added these addresses to ' . $op . ' list. ' . 'Others could not be added.');
                     }
                     $result[] = new HeraldApplyTranscript($failed, false, $op . ' forbidden, these addresses have unsubscribed.');
                 } else {
                     $result[] = new HeraldApplyTranscript($effect, true, 'Added addresses to ' . $op . ' list.');
                 }
                 break;
             case HeraldActionConfig::ACTION_REMOVE_CC:
                 foreach ($effect->getTarget() as $fbid) {
                     $this->remCCs[$fbid] = true;
                 }
                 $result[] = new HeraldApplyTranscript($effect, true, 'Removed addresses from CC list.');
                 break;
             default:
                 throw new Exception("No rules to handle action '{$action}'.");
         }
     }
     return $result;
 }
 public function applyHeraldEffects(array $effects)
 {
     assert_instances_of($effects, 'HeraldEffect');
     $result = array();
     foreach ($effects as $effect) {
         $action = $effect->getAction();
         switch ($action) {
             case HeraldActionConfig::ACTION_NOTHING:
                 $result[] = new HeraldApplyTranscript($effect, true, 'Great success at doing nothing.');
                 break;
             case HeraldActionConfig::ACTION_EMAIL:
                 foreach ($effect->getTarget() as $phid) {
                     $this->emailPHIDs[$phid] = true;
                 }
                 $result[] = new HeraldApplyTranscript($effect, true, 'Added address to email targets.');
                 break;
             case HeraldActionConfig::ACTION_AUDIT:
                 foreach ($effect->getTarget() as $phid) {
                     if (empty($this->auditMap[$phid])) {
                         $this->auditMap[$phid] = array();
                     }
                     $this->auditMap[$phid][] = $effect->getRuleID();
                 }
                 $result[] = new HeraldApplyTranscript($effect, true, 'Triggered an audit.');
                 break;
             case HeraldActionConfig::ACTION_FLAG:
                 $result[] = parent::applyFlagEffect($effect, $this->commit->getPHID());
                 break;
             default:
                 throw new Exception("No rules to handle action '{$action}'.");
         }
     }
     return $result;
 }