mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Fix undefined ACTION_BLOCK class constant in Herald
Summary: Fixes T9054. This didn't get fully cleaned up. Test Plan: Edited several rules, saw actions faithfully represented. Reviewers: joshuaspence, chad Reviewed By: chad Maniphest Tasks: T9054 Differential Revision: https://secure.phabricator.com/D13781
This commit is contained in:
parent
05c571794b
commit
46bd6b30f8
3 changed files with 34 additions and 21 deletions
|
@ -86,6 +86,23 @@ abstract class HeraldAction extends Phobject {
|
|||
return $value;
|
||||
}
|
||||
|
||||
public function getEditorValue(PhabricatorUser $viewer, $target) {
|
||||
try {
|
||||
$type = $this->getHeraldActionStandardType();
|
||||
} catch (PhutilMethodNotImplementedException $ex) {
|
||||
return $target;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case self::STANDARD_PHID_LIST:
|
||||
$handles = $viewer->loadHandles($target);
|
||||
$handles = iterator_to_array($handles);
|
||||
return mpull($handles, 'getName', 'getPHID');
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
final public function setAdapter(HeraldAdapter $adapter) {
|
||||
$this->adapter = $adapter;
|
||||
return $this;
|
||||
|
|
|
@ -770,8 +770,7 @@ abstract class HeraldAdapter extends Phobject {
|
|||
|
||||
public function getEditorValueForCondition(
|
||||
PhabricatorUser $viewer,
|
||||
HeraldCondition $condition,
|
||||
array $handles) {
|
||||
HeraldCondition $condition) {
|
||||
|
||||
$field = $this->requireFieldImplementation($condition->getFieldName());
|
||||
|
||||
|
@ -781,6 +780,17 @@ abstract class HeraldAdapter extends Phobject {
|
|||
$condition->getValue());
|
||||
}
|
||||
|
||||
public function getEditorValueForAction(
|
||||
PhabricatorUser $viewer,
|
||||
HeraldActionRecord $action_record) {
|
||||
|
||||
$action = $this->requireActionImplementation($action_record->getAction());
|
||||
|
||||
return $action->getEditorValue(
|
||||
$viewer,
|
||||
$action_record->getTarget());
|
||||
}
|
||||
|
||||
public function renderRuleAsText(
|
||||
HeraldRule $rule,
|
||||
PhabricatorHandleList $handles,
|
||||
|
|
|
@ -348,8 +348,7 @@ final class HeraldRuleController extends HeraldController {
|
|||
foreach ($rule->getConditions() as $condition) {
|
||||
$value = $adapter->getEditorValueForCondition(
|
||||
$this->getViewer(),
|
||||
$condition,
|
||||
$handles);
|
||||
$condition);
|
||||
|
||||
$serial_conditions[] = array(
|
||||
$condition->getFieldName(),
|
||||
|
@ -366,26 +365,13 @@ final class HeraldRuleController extends HeraldController {
|
|||
if ($rule->getActions()) {
|
||||
$serial_actions = array();
|
||||
foreach ($rule->getActions() as $action) {
|
||||
switch ($action->getAction()) {
|
||||
case HeraldAdapter::ACTION_BLOCK:
|
||||
$current_value = $action->getTarget();
|
||||
break;
|
||||
default:
|
||||
if (is_array($action->getTarget())) {
|
||||
$target_map = array();
|
||||
foreach ((array)$action->getTarget() as $fbid) {
|
||||
$target_map[$fbid] = $handles[$fbid]->getName();
|
||||
}
|
||||
$current_value = $target_map;
|
||||
} else {
|
||||
$current_value = $action->getTarget();
|
||||
}
|
||||
break;
|
||||
}
|
||||
$value = $adapter->getEditorValueForAction(
|
||||
$this->getViewer(),
|
||||
$action);
|
||||
|
||||
$serial_actions[] = array(
|
||||
$action->getAction(),
|
||||
$current_value,
|
||||
$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue