Differential D20741 Diff 49457 src/applications/transactions/xaction/PhabricatorEditEngineSubtypeTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/xaction/PhabricatorEditEngineSubtypeTransaction.php
Show All 19 Lines | public function getTitle() { | ||||
return pht( | return pht( | ||||
'%s changed the subtype of this form from %s to %s.', | '%s changed the subtype of this form from %s to %s.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
$this->renderOldValue(), | $this->renderOldValue(), | ||||
$this->renderNewValue()); | $this->renderNewValue()); | ||||
} | } | ||||
public function validateTransactions($object, array $xactions) { | public function validateTransactions($object, array $xactions) { | ||||
$map = $object->getEngine() | $errors = array(); | ||||
if (!$xactions) { | |||||
return $errors; | |||||
} | |||||
$engine = $object->getEngine(); | |||||
if (!$engine->supportsSubtypes()) { | |||||
foreach ($xactions as $xaction) { | |||||
$errors[] = $this->newInvalidError( | |||||
pht( | |||||
'Edit engine (of class "%s") does not support subtypes, so '. | |||||
'subtype transactions can not be applied to it.', | |||||
get_class($engine)), | |||||
$xaction); | |||||
} | |||||
return $errors; | |||||
} | |||||
$map = $engine | |||||
->setViewer($this->getActor()) | ->setViewer($this->getActor()) | ||||
->newSubtypeMap(); | ->newSubtypeMap(); | ||||
$errors = array(); | |||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$new = $xaction->getNewValue(); | $new = $xaction->getNewValue(); | ||||
if ($map->isValidSubtype($new)) { | if ($map->isValidSubtype($new)) { | ||||
continue; | continue; | ||||
} | } | ||||
$errors[] = $this->newInvalidError( | $errors[] = $this->newInvalidError( | ||||
pht('Subtype "%s" is not a valid subtype.', $new), | pht('Subtype "%s" is not a valid subtype.', $new), | ||||
$xaction); | $xaction); | ||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
} | } |