mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
f6f9d78f3a
Summary: Ref T5861. Currently, mail tags are hard-coded; move them into applications. Each Editor defines its own tags. This has zero impact on the UI or behavior. Test Plan: - Checked/unchecked some options, saved form. - Swapped back to `master` and saw exactly the same values. Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5861 Differential Revision: https://secure.phabricator.com/D10238
103 lines
2.6 KiB
PHP
103 lines
2.6 KiB
PHP
<?php
|
|
|
|
final class NuanceSourceEditor
|
|
extends PhabricatorApplicationTransactionEditor {
|
|
|
|
public function getEditorApplicationClass() {
|
|
return 'PhabricatorNuanceApplication';
|
|
}
|
|
|
|
public function getEditorObjectsDescription() {
|
|
return pht('Nuance Sources');
|
|
}
|
|
|
|
public function getTransactionTypes() {
|
|
$types = parent::getTransactionTypes();
|
|
|
|
$types[] = NuanceSourceTransaction::TYPE_NAME;
|
|
|
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
|
|
|
return $types;
|
|
}
|
|
|
|
protected function getCustomTransactionOldValue(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case NuanceSourceTransaction::TYPE_NAME:
|
|
return $object->getName();
|
|
}
|
|
|
|
return parent::getCustomTransactionOldValue($object, $xaction);
|
|
}
|
|
|
|
protected function getCustomTransactionNewValue(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case NuanceSourceTransaction::TYPE_NAME:
|
|
return $xaction->getNewValue();
|
|
}
|
|
|
|
return parent::getCustomTransactionNewValue($object, $xaction);
|
|
}
|
|
|
|
protected function applyCustomInternalTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case NuanceSourceTransaction::TYPE_NAME:
|
|
$object->setName($xaction->getNewValue());
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected function applyCustomExternalTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
case NuanceSourceTransaction::TYPE_NAME:
|
|
return;
|
|
}
|
|
|
|
return parent::applyCustomExternalTransaction($object, $xaction);
|
|
}
|
|
|
|
protected function validateTransaction(
|
|
PhabricatorLiskDAO $object,
|
|
$type,
|
|
array $xactions) {
|
|
|
|
$errors = parent::validateTransaction($object, $type, $xactions);
|
|
|
|
switch ($type) {
|
|
case NuanceSourceTransaction::TYPE_NAME:
|
|
$missing = $this->validateIsEmptyTextField(
|
|
$object->getName(),
|
|
$xactions);
|
|
|
|
if ($missing) {
|
|
$error = new PhabricatorApplicationTransactionValidationError(
|
|
$type,
|
|
pht('Required'),
|
|
pht('Source name is required.'),
|
|
nonempty(last($xactions), null));
|
|
|
|
$error->setIsMissingFieldError(true);
|
|
$errors[] = $error;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
}
|