Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/editor/NuanceSourceEditor.php
| Show All 9 Lines | final class NuanceSourceEditor | ||||
| public function getEditorObjectsDescription() { | public function getEditorObjectsDescription() { | ||||
| return pht('Nuance Sources'); | return pht('Nuance Sources'); | ||||
| } | } | ||||
| public function getTransactionTypes() { | public function getTransactionTypes() { | ||||
| $types = parent::getTransactionTypes(); | $types = parent::getTransactionTypes(); | ||||
| $types[] = NuanceSourceTransaction::TYPE_NAME; | $types[] = NuanceSourceTransaction::TYPE_NAME; | ||||
| $types[] = NuanceSourceTransaction::TYPE_DEFAULT_QUEUE; | |||||
| $types[] = PhabricatorTransactions::TYPE_EDGE; | $types[] = PhabricatorTransactions::TYPE_EDGE; | ||||
| $types[] = PhabricatorTransactions::TYPE_COMMENT; | $types[] = PhabricatorTransactions::TYPE_COMMENT; | ||||
| $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; | ||||
| $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; | ||||
| return $types; | return $types; | ||||
| } | } | ||||
| protected function getCustomTransactionOldValue( | protected function getCustomTransactionOldValue( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case NuanceSourceTransaction::TYPE_NAME: | case NuanceSourceTransaction::TYPE_NAME: | ||||
| return $object->getName(); | return $object->getName(); | ||||
| case NuanceSourceTransaction::TYPE_DEFAULT_QUEUE: | |||||
| return $object->getDefaultQueuePHID(); | |||||
| } | } | ||||
| return parent::getCustomTransactionOldValue($object, $xaction); | return parent::getCustomTransactionOldValue($object, $xaction); | ||||
| } | } | ||||
| protected function getCustomTransactionNewValue( | protected function getCustomTransactionNewValue( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case NuanceSourceTransaction::TYPE_NAME: | case NuanceSourceTransaction::TYPE_NAME: | ||||
| case NuanceSourceTransaction::TYPE_DEFAULT_QUEUE: | |||||
| return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
| } | } | ||||
| return parent::getCustomTransactionNewValue($object, $xaction); | return parent::getCustomTransactionNewValue($object, $xaction); | ||||
| } | } | ||||
| protected function applyCustomInternalTransaction( | protected function applyCustomInternalTransaction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case NuanceSourceTransaction::TYPE_NAME: | case NuanceSourceTransaction::TYPE_NAME: | ||||
| $object->setName($xaction->getNewValue()); | $object->setName($xaction->getNewValue()); | ||||
| break; | break; | ||||
| case NuanceSourceTransaction::TYPE_DEFAULT_QUEUE: | |||||
| $object->setDefaultQueuePHID($xaction->getNewValue()); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| protected function applyCustomExternalTransaction( | protected function applyCustomExternalTransaction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
| switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
| case NuanceSourceTransaction::TYPE_NAME: | case NuanceSourceTransaction::TYPE_NAME: | ||||
| case NuanceSourceTransaction::TYPE_DEFAULT_QUEUE: | |||||
| return; | return; | ||||
| } | } | ||||
| return parent::applyCustomExternalTransaction($object, $xaction); | return parent::applyCustomExternalTransaction($object, $xaction); | ||||
| } | } | ||||
| protected function validateTransaction( | protected function validateTransaction( | ||||
| PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
| Show All 14 Lines | switch ($type) { | ||||
| pht('Required'), | pht('Required'), | ||||
| pht('Source name is required.'), | pht('Source name is required.'), | ||||
| nonempty(last($xactions), null)); | nonempty(last($xactions), null)); | ||||
| $error->setIsMissingFieldError(true); | $error->setIsMissingFieldError(true); | ||||
| $errors[] = $error; | $errors[] = $error; | ||||
| } | } | ||||
| break; | break; | ||||
| case NuanceSourceTransaction::TYPE_DEFAULT_QUEUE: | |||||
| foreach ($xactions as $xaction) { | |||||
| if (!$xaction->getNewValue()) { | |||||
| $error = new PhabricatorApplicationTransactionValidationError( | |||||
| $type, | |||||
| pht('Required'), | |||||
| pht('Sources must have a default queue.'), | |||||
| $xaction); | |||||
| $error->setIsMissingFieldError(true); | |||||
| $errors[] = $error; | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| return $errors; | return $errors; | ||||
| } | } | ||||
| } | } | ||||