Differential D17020 Diff 41026 src/applications/release/changes/actions/ReleaseChangeRequestAction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/release/changes/actions/ReleaseChangeRequestAction.php
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
<?php | |||||
abstract class ReleaseChangeRequestAction extends Phobject { | |||||
public abstract function getActionName(); | |||||
public abstract function getActionIcon(); | |||||
public abstract function getActionKey(); | |||||
/** | |||||
* Actually do work. Should return a URI to redirect to. | |||||
*/ | |||||
public abstract function act( | |||||
ReleaseChangeRequest $change, | |||||
AphrontRequest $request); | |||||
/** | |||||
* return prompt to show the user in the confirmation dialog for this action. | |||||
*/ | |||||
public abstract function getPrompt(ReleaseChangeRequest $change); | |||||
/** | |||||
* return Title for the confirmation dialog for this action. | |||||
*/ | |||||
public abstract function getFormTitle(ReleaseChangeRequest $change); | |||||
public function isEnabledForRequest(ReleaseChangeRequest $change) { | |||||
return true; | |||||
} | |||||
public function assertPolicy( | |||||
PhabricatorUser $user, | |||||
ReleaseChangeRequest $change) { | |||||
// TBD | |||||
// default to view + edit? | |||||
} | |||||
public function getActionHref(ReleaseChangeRequest $change) { | |||||
$phid = $change->getPHID(); | |||||
$key = $this->getActionKey(); | |||||
return "/release/changerequest/action/{$phid}/{$key}/"; | |||||
} | |||||
public function generateActions() { | |||||
return array($this); | |||||
} | |||||
public static function getAllActions() { | |||||
return id(new PhutilClassMapQuery()) | |||||
->setAncestorClass(__CLASS__) | |||||
->setExpandMethod('generateActions') | |||||
->setUniqueMethod('getActionKey') | |||||
->execute(); | |||||
} | |||||
public static function getActionByKey($action_key) { | |||||
$action = idx(self::getAllActions(), $action_key); | |||||
if ($action) { | |||||
return $action; | |||||
} | |||||
throw new Exception(pht( | |||||
'Change Request Action not found for action key "%s".', | |||||
$action_key)); | |||||
} | |||||
} |