1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 19:32:40 +01:00
phorge-phorge/src/applications/maniphest/herald/ManiphestTaskStatusHeraldField.php
epriestley b2b739c709 Reduce code duplication in Herald fields
Summary:
Ref T8726. I want to modularize values and reduce how hard-coded / copypasta'd they are.

  - Rename `get...StandardCondition()` to `get...StandardType()`, since we can drive both conditions and values from it.
  - Rename `STANDARD_LIST` to `STANDARD_PHID_LIST` for consistency: all "lists" are lists of PHIDs.
  - For all standard types which don't require typehaeads, lift their logic into the base class.
  - I'll lift typeaheads soon, but need to generalize them first.

Test Plan: Edited various Herald rules, saw value UI generate correctly.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

Differential Revision: https://secure.phabricator.com/D13612
2015-07-16 14:11:44 -07:00

55 lines
1.1 KiB
PHP

<?php
final class ManiphestTaskStatusHeraldField
extends ManiphestTaskHeraldField {
const FIELDCONST = 'taskstatus';
public function getHeraldFieldName() {
return pht('Status');
}
public function getHeraldFieldValue($object) {
return $object->getStatus();
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID;
}
public function getHeraldFieldValueType($condition) {
return HeraldAdapter::VALUE_TASK_STATUS;
}
public function renderConditionValue(
PhabricatorUser $viewer,
$value) {
$status_map = ManiphestTaskStatus::getTaskStatusMap();
$value = (array)$value;
foreach ($value as $index => $val) {
$name = idx($status_map, $val);
if ($name !== null) {
$value[$index] = $name;
}
}
return implode(', ', $value);
}
public function getEditorValue(
PhabricatorUser $viewer,
$value) {
$status_map = ManiphestTaskStatus::getTaskStatusMap();
$value_map = array();
foreach ($value as $status) {
$value_map[$status] = idx($status_map, $status, $status);
}
return $value_map;
}
}