Changeset View
Changeset View
Standalone View
Standalone View
src/applications/pholio/herald/HeraldPholioMockAdapter.php
- This file was moved from src/applications/herald/adapter/HeraldPholioMockAdapter.php.
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | switch ($rule_type) { | ||||
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: | case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: | ||||
return true; | return true; | ||||
case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: | case HeraldRuleTypeConfig::RULE_TYPE_OBJECT: | ||||
default: | default: | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
public function getFields() { | |||||
return array_merge( | |||||
array( | |||||
self::FIELD_TITLE, | |||||
self::FIELD_BODY, | |||||
self::FIELD_AUTHOR, | |||||
), | |||||
parent::getFields()); | |||||
} | |||||
public function getActions($rule_type) { | public function getActions($rule_type) { | ||||
switch ($rule_type) { | switch ($rule_type) { | ||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: | case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: | ||||
return array_merge( | return array_merge( | ||||
array( | array( | ||||
self::ACTION_ADD_CC, | self::ACTION_ADD_CC, | ||||
self::ACTION_REMOVE_CC, | self::ACTION_REMOVE_CC, | ||||
self::ACTION_NOTHING, | self::ACTION_NOTHING, | ||||
Show All 14 Lines | final class HeraldPholioMockAdapter extends HeraldAdapter { | ||||
public function getPHID() { | public function getPHID() { | ||||
return $this->getMock()->getPHID(); | return $this->getMock()->getPHID(); | ||||
} | } | ||||
public function getHeraldName() { | public function getHeraldName() { | ||||
return 'M'.$this->getMock()->getID(); | return 'M'.$this->getMock()->getID(); | ||||
} | } | ||||
public function getHeraldField($field) { | |||||
switch ($field) { | |||||
case self::FIELD_TITLE: | |||||
return $this->getMock()->getName(); | |||||
case self::FIELD_BODY: | |||||
return $this->getMock()->getDescription(); | |||||
case self::FIELD_AUTHOR: | |||||
return $this->getMock()->getAuthorPHID(); | |||||
} | |||||
return parent::getHeraldField($field); | |||||
} | |||||
public function applyHeraldEffects(array $effects) { | |||||
assert_instances_of($effects, 'HeraldEffect'); | |||||
$result = array(); | |||||
foreach ($effects as $effect) { | |||||
$action = $effect->getAction(); | |||||
switch ($action) { | |||||
default: | |||||
$result[] = $this->applyStandardEffect($effect); | |||||
break; | |||||
} | |||||
} | |||||
return $result; | |||||
} | |||||
} | } |