Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/editor/DiffusionURIEditor.php
- This file was added.
| <?php | |||||
| final class DiffusionURIEditor | |||||
| extends PhabricatorApplicationTransactionEditor { | |||||
| public function getEditorApplicationClass() { | |||||
| return 'PhabricatorDiffusionApplication'; | |||||
| } | |||||
| public function getEditorObjectsDescription() { | |||||
| return pht('Diffusion URIs'); | |||||
| } | |||||
| public function getTransactionTypes() { | |||||
| $types = parent::getTransactionTypes(); | |||||
| $types[] = PhabricatorRepositoryURITransaction::TYPE_URI; | |||||
| return $types; | |||||
| } | |||||
| protected function getCustomTransactionOldValue( | |||||
| PhabricatorLiskDAO $object, | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| switch ($xaction->getTransactionType()) { | |||||
| case PhabricatorRepositoryURITransaction::TYPE_URI: | |||||
| return $object->getURI(); | |||||
| } | |||||
| return parent::getCustomTransactionOldValue($object, $xaction); | |||||
| } | |||||
| protected function getCustomTransactionNewValue( | |||||
| PhabricatorLiskDAO $object, | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| switch ($xaction->getTransactionType()) { | |||||
| case PhabricatorRepositoryURITransaction::TYPE_URI: | |||||
| return $xaction->getNewValue(); | |||||
| } | |||||
| return parent::getCustomTransactionNewValue($object, $xaction); | |||||
| } | |||||
| protected function applyCustomInternalTransaction( | |||||
| PhabricatorLiskDAO $object, | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| switch ($xaction->getTransactionType()) { | |||||
| case PhabricatorRepositoryURITransaction::TYPE_URI: | |||||
| $object->setURI($xaction->getNewValue()); | |||||
| break; | |||||
| } | |||||
| } | |||||
| protected function applyCustomExternalTransaction( | |||||
| PhabricatorLiskDAO $object, | |||||
| PhabricatorApplicationTransaction $xaction) { | |||||
| switch ($xaction->getTransactionType()) { | |||||
| case PhabricatorRepositoryURITransaction::TYPE_URI: | |||||
| return; | |||||
| } | |||||
| return parent::applyCustomExternalTransaction($object, $xaction); | |||||
| } | |||||
| protected function validateTransaction( | |||||
| PhabricatorLiskDAO $object, | |||||
| $type, | |||||
| array $xactions) { | |||||
| $errors = parent::validateTransaction($object, $type, $xactions); | |||||
| switch ($type) { | |||||
| case PhabricatorRepositoryURITransaction::TYPE_URI: | |||||
| $missing = $this->validateIsEmptyTextField( | |||||
| $object->getURI(), | |||||
| $xactions); | |||||
| if ($missing) { | |||||
| $error = new PhabricatorApplicationTransactionValidationError( | |||||
| $type, | |||||
| pht('Required'), | |||||
| pht('Repository URI is required.'), | |||||
| nonempty(last($xactions), null)); | |||||
| $error->setIsMissingFieldError(true); | |||||
| $errors[] = $error; | |||||
| break; | |||||
| } | |||||
| break; | |||||
| } | |||||
| return $errors; | |||||
| } | |||||
| } | |||||