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;
|
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) {
|
final public function setAdapter(HeraldAdapter $adapter) {
|
||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -770,8 +770,7 @@ abstract class HeraldAdapter extends Phobject {
|
||||||
|
|
||||||
public function getEditorValueForCondition(
|
public function getEditorValueForCondition(
|
||||||
PhabricatorUser $viewer,
|
PhabricatorUser $viewer,
|
||||||
HeraldCondition $condition,
|
HeraldCondition $condition) {
|
||||||
array $handles) {
|
|
||||||
|
|
||||||
$field = $this->requireFieldImplementation($condition->getFieldName());
|
$field = $this->requireFieldImplementation($condition->getFieldName());
|
||||||
|
|
||||||
|
@ -781,6 +780,17 @@ abstract class HeraldAdapter extends Phobject {
|
||||||
$condition->getValue());
|
$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(
|
public function renderRuleAsText(
|
||||||
HeraldRule $rule,
|
HeraldRule $rule,
|
||||||
PhabricatorHandleList $handles,
|
PhabricatorHandleList $handles,
|
||||||
|
|
|
@ -348,8 +348,7 @@ final class HeraldRuleController extends HeraldController {
|
||||||
foreach ($rule->getConditions() as $condition) {
|
foreach ($rule->getConditions() as $condition) {
|
||||||
$value = $adapter->getEditorValueForCondition(
|
$value = $adapter->getEditorValueForCondition(
|
||||||
$this->getViewer(),
|
$this->getViewer(),
|
||||||
$condition,
|
$condition);
|
||||||
$handles);
|
|
||||||
|
|
||||||
$serial_conditions[] = array(
|
$serial_conditions[] = array(
|
||||||
$condition->getFieldName(),
|
$condition->getFieldName(),
|
||||||
|
@ -366,26 +365,13 @@ final class HeraldRuleController extends HeraldController {
|
||||||
if ($rule->getActions()) {
|
if ($rule->getActions()) {
|
||||||
$serial_actions = array();
|
$serial_actions = array();
|
||||||
foreach ($rule->getActions() as $action) {
|
foreach ($rule->getActions() as $action) {
|
||||||
switch ($action->getAction()) {
|
$value = $adapter->getEditorValueForAction(
|
||||||
case HeraldAdapter::ACTION_BLOCK:
|
$this->getViewer(),
|
||||||
$current_value = $action->getTarget();
|
$action);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$serial_actions[] = array(
|
$serial_actions[] = array(
|
||||||
$action->getAction(),
|
$action->getAction(),
|
||||||
$current_value,
|
$value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue