Differential D19443 Diff 46541 src/applications/repository/xaction/PhabricatorRepositoryIdentityAssignTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/xaction/PhabricatorRepositoryIdentityAssignTransaction.php
Show All 15 Lines | final class PhabricatorRepositoryIdentityAssignTransaction | ||||
public function getTitle() { | public function getTitle() { | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
if (!$old) { | if (!$old) { | ||||
return pht( | return pht( | ||||
'%s assigned this identity to %s.', | '%s assigned this identity to %s.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
$this->renderHandle($new)); | $this->renderIdentityHandle($new)); | ||||
} else if (!$new) { | } else if (!$new) { | ||||
return pht( | return pht( | ||||
'%s removed %s as the assignee of this identity.', | '%s removed %s as the assignee of this identity.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
$this->renderHandle($old)); | $this->renderIdentityHandle($old)); | ||||
} else { | } else { | ||||
return pht( | return pht( | ||||
'%s changed the assigned user for this identity from %s to %s.', | '%s changed the assigned user for this identity from %s to %s.', | ||||
$this->renderAuthor(), | $this->renderAuthor(), | ||||
$this->renderHandle($old), | $this->renderIdentityHandle($old), | ||||
$this->renderHandle($new)); | $this->renderIdentityHandle($new)); | ||||
} | |||||
} | |||||
private function renderIdentityHandle($handle) { | |||||
$unassigned_token = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN; | |||||
if ($handle === $unassigned_token) { | |||||
return phutil_tag('em', array(), pht('Explicitly Unassigned')); | |||||
} else { | |||||
return $this->renderHandle($handle); | |||||
} | } | ||||
} | } | ||||
public function validateTransactions($object, array $xactions) { | public function validateTransactions($object, array $xactions) { | ||||
$errors = array(); | $errors = array(); | ||||
$unassigned_token = DiffusionIdentityUnassignedDatasource::FUNCTION_TOKEN; | |||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$old = $xaction->getOldValue(); | $old = $xaction->getOldValue(); | ||||
$new = $xaction->getNewValue(); | $new = $xaction->getNewValue(); | ||||
if (!strlen($new)) { | if (!strlen($new)) { | ||||
continue; | continue; | ||||
} | } | ||||
if ($new === $old) { | if ($new === $old) { | ||||
continue; | continue; | ||||
} | } | ||||
if ($new === $unassigned_token) { | |||||
continue; | |||||
} | |||||
$assignee_list = id(new PhabricatorPeopleQuery()) | $assignee_list = id(new PhabricatorPeopleQuery()) | ||||
->setViewer($this->getActor()) | ->setViewer($this->getActor()) | ||||
->withPHIDs(array($new)) | ->withPHIDs(array($new)) | ||||
->execute(); | ->execute(); | ||||
if (!$assignee_list) { | if (!$assignee_list) { | ||||
$errors[] = $this->newInvalidError( | $errors[] = $this->newInvalidError( | ||||
pht('User "%s" is not a valid user.', | pht('User "%s" is not a valid user.', | ||||
$new)); | $new)); | ||||
} | } | ||||
epriestley: I think you can just do `if ($new === ThingeySource::FUNCTION) { continue; }` a little above. | |||||
} | } | ||||
return $errors; | return $errors; | ||||
} | } | ||||
} | } |
I think you can just do if ($new === ThingeySource::FUNCTION) { continue; } a little above.