Path: blob/master/src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php
12256 views
<?php12final class DifferentialRevisionPlanChangesTransaction3extends DifferentialRevisionActionTransaction {45const TRANSACTIONTYPE = 'differential.revision.plan';6const ACTIONKEY = 'plan-changes';78protected function getRevisionActionLabel(9DifferentialRevision $revision,10PhabricatorUser $viewer) {11return pht('Plan Changes');12}1314protected function getRevisionActionDescription(15DifferentialRevision $revision,16PhabricatorUser $viewer) {17return pht(18'This revision will be removed from review queues until it is revised.');19}2021public function getIcon() {22return 'fa-headphones';23}2425public function getColor() {26return 'red';27}2829protected function getRevisionActionOrder() {30return 200;31}3233public function getActionName() {34return pht('Planned Changes');35}3637public function getCommandKeyword() {38return 'planchanges';39}4041public function getCommandAliases() {42return array(43'rethink',44);45}4647public function getCommandSummary() {48return pht('Plan changes to a revision.');49}5051public function generateOldValue($object) {52return $object->isChangePlanned();53}5455public function applyInternalEffects($object, $value) {56$status_planned = DifferentialRevisionStatus::CHANGES_PLANNED;57$object->setModernRevisionStatus($status_planned);58}5960protected function validateAction($object, PhabricatorUser $viewer) {61if ($object->isDraft()) {6263// See PHI346. Until the "Draft" state fully unprototypes, allow drafts64// to be moved to "changes planned" via the API. This preserves the65// behavior of "arc diff --plan-changes". We still prevent this66// transition from the web UI.67// TODO: Remove this once drafts leave prototype.6869$editor = $this->getEditor();70$type_web = PhabricatorWebContentSource::SOURCECONST;71if ($editor->getContentSource()->getSource() == $type_web) {72throw new Exception(73pht('You can not plan changes to a draft revision.'));74}75}7677if ($object->isChangePlanned()) {78throw new Exception(79pht(80'You can not request review of this revision because this '.81'revision is already under review and the action would have '.82'no effect.'));83}8485if ($object->isClosed()) {86throw new Exception(87pht(88'You can not plan changes to this this revision because it has '.89'already been closed.'));90}9192if (!$this->isViewerRevisionAuthor($object, $viewer)) {93throw new Exception(94pht(95'You can not plan changes to this revision because you do not '.96'own it. Only the author of a revision can plan changes to it.'));97}98}99100public function getTitle() {101if ($this->isDraftDemotion()) {102return pht(103'%s returned this revision to the author for changes because remote '.104'builds failed.',105$this->renderAuthor());106} else {107return pht(108'%s planned changes to this revision.',109$this->renderAuthor());110}111}112113public function getTitleForFeed() {114return pht(115'%s planned changes to %s.',116$this->renderAuthor(),117$this->renderObject());118}119120private function isDraftDemotion() {121return (bool)$this->getMetadataValue('draft.demote');122}123124public function getTransactionTypeForConduit($xaction) {125return 'plan-changes';126}127128public function getFieldValuesForConduit($object, $data) {129return array();130}131132}133134135