3 abstract class DiffusionCommitActionTransaction
4 extends DiffusionCommitTransactionType
{
6 final public function getCommitActionKey() {
7 return $this->getPhobjectClassConstant('ACTIONKEY', 32);
10 public function isActionAvailable($object, PhabricatorUser
$viewer) {
12 $this->validateAction($object, $viewer);
14 } catch (Exception
$ex) {
19 abstract protected function validateAction($object, PhabricatorUser
$viewer);
20 abstract protected function getCommitActionLabel();
22 public function getCommandKeyword() {
26 public function getCommandAliases() {
30 public function getCommandSummary() {
34 protected function getCommitActionOrder() {
38 public function getCommitActionOrderVector() {
39 return id(new PhutilSortVector())
40 ->addInt($this->getCommitActionOrder());
43 protected function getCommitActionGroupKey() {
44 return DiffusionCommitEditEngine
::ACTIONGROUP_COMMIT
;
47 protected function getCommitActionDescription() {
51 public static function loadAllActions() {
52 return id(new PhutilClassMapQuery())
53 ->setAncestorClass(__CLASS__
)
54 ->setUniqueMethod('getCommitActionKey')
58 protected function isViewerCommitAuthor(
59 PhabricatorRepositoryCommit
$commit,
60 PhabricatorUser
$viewer) {
62 if (!$viewer->getPHID()) {
66 return ($viewer->getPHID() === $commit->getEffectiveAuthorPHID());
69 public function newEditField(
70 PhabricatorRepositoryCommit
$commit,
71 PhabricatorUser
$viewer) {
73 // Actions in the "audit" group, like "Accept Commit", do not require
74 // that the actor be able to edit the commit.
75 $group_audit = DiffusionCommitEditEngine
::ACTIONGROUP_AUDIT
;
76 $is_audit = ($this->getCommitActionGroupKey() == $group_audit);
78 $field = id(new PhabricatorApplyEditField())
79 ->setKey($this->getCommitActionKey())
80 ->setTransactionType($this->getTransactionTypeConstant())
81 ->setCanApplyWithoutEditCapability($is_audit)
84 if ($this->isActionAvailable($commit, $viewer)) {
85 $label = $this->getCommitActionLabel();
86 if ($label !== null) {
87 $field->setCommentActionLabel($label);
89 $description = $this->getCommitActionDescription();
90 $field->setActionDescription($description);
92 $group_key = $this->getCommitActionGroupKey();
93 $field->setCommentActionGroupKey($group_key);
95 $field->setActionConflictKey('commit.action');
102 public function validateTransactions($object, array $xactions) {
104 $actor = $this->getActor();
106 $action_exception = null;
108 $this->validateAction($object, $actor);
109 } catch (Exception
$ex) {
110 $action_exception = $ex;
113 foreach ($xactions as $xaction) {
114 if ($action_exception) {
115 $errors[] = $this->newInvalidError(
116 $action_exception->getMessage(),