Differential D19443 Diff 46509 src/applications/repository/xaction/PhabricatorRepositoryIdentityAssignTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/xaction/PhabricatorRepositoryIdentityAssignTransaction.php
- This file was added.
<?php | |||||
final class PhabricatorRepositoryIdentityAssignTransaction | |||||
extends PhabricatorRepositoryIdentityTransactionType { | |||||
const TRANSACTIONTYPE = 'repository:identity:assign'; | |||||
public function generateOldValue($object) { | |||||
return nonempty($object->getManuallySetUserPHID(), null); | |||||
} | |||||
public function applyInternalEffects($object, $value) { | |||||
$object->setManuallySetUserPHID($value); | |||||
} | |||||
public function getTitle() { | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
if (!$old) { | |||||
return pht( | |||||
'%s assigned this identity to %s.', | |||||
$this->renderAuthor(), | |||||
$this->renderHandle($new)); | |||||
} else if (!$new) { | |||||
return pht( | |||||
'%s removed %s as the assignee of this identity.', | |||||
$this->renderAuthor(), | |||||
$this->renderHandle($old)); | |||||
} else { | |||||
return pht( | |||||
'%s changed the assigned user for this identity from %s to %s.', | |||||
$this->renderAuthor(), | |||||
$this->renderHandle($old), | |||||
$this->renderHandle($new)); | |||||
} | |||||
} | |||||
public function validateTransactions($object, array $xactions) { | |||||
$errors = array(); | |||||
foreach ($xactions as $xaction) { | |||||
$old = $xaction->getOldValue(); | |||||
$new = $xaction->getNewValue(); | |||||
if (!strlen($new)) { | |||||
continue; | |||||
} | |||||
if ($new === $old) { | |||||
continue; | |||||
} | |||||
$assignee_list = id(new PhabricatorPeopleQuery()) | |||||
->setViewer($this->getActor()) | |||||
->withPHIDs(array($new)) | |||||
->execute(); | |||||
// TODO: turn this back on when I figure out how to check for | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
Done Inline ActionsI think you can just do if ($new === ThingeySource::FUNCTION) { continue; } a little above. epriestley: I think you can just do `if ($new === ThingeySource::FUNCTION) { continue; }` a little above. | |||||
// 'unassigned()' | |||||
// if (!$assignee_list) { | |||||
// $errors[] = $this->newInvalidError( | |||||
// pht('User "%s" is not a valid user.', | |||||
// $new)); | |||||
// } | |||||
} | |||||
return $errors; | |||||
} | |||||
} |
This comment has a TODO.