3 final class PhabricatorRepositoryCallsignTransaction
4 extends PhabricatorRepositoryTransactionType
{
6 const TRANSACTIONTYPE
= 'repo:callsign';
8 public function generateOldValue($object) {
9 return $object->getCallsign();
12 public function generateNewValue($object, $value) {
20 public function applyInternalEffects($object, $value) {
21 $object->setCallsign($value);
24 public function getTitle() {
25 $old = $this->getOldValue();
26 $new = $this->getNewValue();
30 '%s set the callsign for this repository to %s.',
31 $this->renderAuthor(),
32 $this->renderNewValue());
33 } else if (!strlen($new)) {
35 '%s removed the callsign (%s) for this repository.',
36 $this->renderAuthor(),
37 $this->renderOldValue());
40 '%s changed the callsign for this repository from %s to %s.',
41 $this->renderAuthor(),
42 $this->renderOldValue(),
43 $this->renderNewValue());
47 public function validateTransactions($object, array $xactions) {
50 foreach ($xactions as $xaction) {
51 $old = $xaction->getOldValue();
52 $new = $xaction->getNewValue();
63 PhabricatorRepository
::assertValidCallsign($new);
64 } catch (Exception
$ex) {
65 $errors[] = $this->newInvalidError(
71 $other = id(new PhabricatorRepositoryQuery())
72 ->setViewer(PhabricatorUser
::getOmnipotentUser())
73 ->withCallsigns(array($new))
75 if ($other && ($other->getID() !== $object->getID())) {
76 $errors[] = $this->newError(
79 'The selected callsign ("%s") is already in use by another '.
80 'repository. Choose a unique callsign.',