Path: blob/master/src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
12256 views
<?php12final class DifferentialRevisionCommandeerTransaction3extends DifferentialRevisionActionTransaction {45const TRANSACTIONTYPE = 'differential.revision.commandeer';6const ACTIONKEY = 'commandeer';78protected function getRevisionActionLabel(9DifferentialRevision $revision,10PhabricatorUser $viewer) {11return pht('Commandeer Revision');12}1314protected function getRevisionActionDescription(15DifferentialRevision $revision,16PhabricatorUser $viewer) {17return pht('You will take control of this revision and become its author.');18}1920public function getIcon() {21return 'fa-flag';22}2324public function getColor() {25return 'sky';26}2728protected function getRevisionActionOrder() {29return 700;30}3132public function getActionName() {33return pht('Commandeered');34}3536public function getCommandKeyword() {37return 'commandeer';38}3940public function getCommandAliases() {41return array(42'claim',43);44}4546public function getCommandSummary() {47return pht('Commandeer a revision.');48}4950public function generateOldValue($object) {51return $object->getAuthorPHID();52}5354public function generateNewValue($object, $value) {55$actor = $this->getActor();56return $actor->getPHID();57}5859public function applyInternalEffects($object, $value) {60$object->setAuthorPHID($value);61}6263protected function validateAction($object, PhabricatorUser $viewer) {64// If a revision has already landed, we generally want to discourage65// reopening and reusing it since this tends to create a big mess (users66// should create a new revision instead). Thus, we stop you from67// commandeering closed revisions.6869// See PHI985. If the revision was abandoned, there's no peril in allowing70// the commandeer since the change (likely) never actually landed. So71// it's okay to commandeer abandoned revisions.7273if ($object->isClosed() && !$object->isAbandoned()) {74throw new Exception(75pht(76'You can not commandeer this revision because it has already '.77'been closed. You can only commandeer open or abandoned '.78'revisions.'));79}8081if ($this->isViewerRevisionAuthor($object, $viewer)) {82throw new Exception(83pht(84'You can not commandeer this revision because you are already '.85'the author.'));86}87}8889public function getTitle() {90return pht(91'%s commandeered this revision.',92$this->renderAuthor());93}9495public function getTitleForFeed() {96return pht(97'%s commandeered %s.',98$this->renderAuthor(),99$this->renderObject());100}101102public function getTransactionTypeForConduit($xaction) {103return 'commandeer';104}105106public function getFieldValuesForConduit($object, $data) {107return array();108}109110}111112113