[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 abstract class DifferentialLandingStrategy { 4 5 public abstract function processLandRequest( 6 AphrontRequest $request, 7 DifferentialRevision $revision, 8 PhabricatorRepository $repository); 9 10 /** 11 * @return PhabricatorActionView or null. 12 */ 13 abstract function createMenuItem( 14 PhabricatorUser $viewer, 15 DifferentialRevision $revision, 16 PhabricatorRepository $repository); 17 18 /** 19 * @return PhabricatorActionView which can be attached to the revision view. 20 */ 21 protected function createActionView($revision, $name) { 22 $strategy = get_class($this); 23 $revision_id = $revision->getId(); 24 return id(new PhabricatorActionView()) 25 ->setRenderAsForm(true) 26 ->setWorkflow(true) 27 ->setName($name) 28 ->setHref("/differential/revision/land/{$revision_id}/{$strategy}/"); 29 } 30 31 /** 32 * Check if this action should be disabled, and explain why. 33 * 34 * By default, this method checks for push permissions, and for the 35 * revision being Accepted. 36 * 37 * @return False for "not disabled"; human-readable text explaining why, if 38 * it is disabled. 39 */ 40 public function isActionDisabled( 41 PhabricatorUser $viewer, 42 DifferentialRevision $revision, 43 PhabricatorRepository $repository) { 44 45 $status = $revision->getStatus(); 46 if ($status != ArcanistDifferentialRevisionStatus::ACCEPTED) { 47 return pht('Only Accepted revisions can be landed.'); 48 } 49 50 if (!PhabricatorPolicyFilter::hasCapability( 51 $viewer, 52 $repository, 53 DiffusionPushCapability::CAPABILITY)) { 54 return pht('You do not have permissions to push to this repository.'); 55 } 56 57 return false; 58 } 59 60 /** 61 * Might break if repository is not Git. 62 */ 63 protected function getGitWorkspace(PhabricatorRepository $repository) { 64 try { 65 return DifferentialGetWorkingCopy::getCleanGitWorkspace($repository); 66 } catch (Exception $e) { 67 throw new PhutilProxyException('Failed to allocate a workspace', $e); 68 } 69 } 70 71 /** 72 * Might break if repository is not Mercurial. 73 */ 74 protected function getMercurialWorkspace(PhabricatorRepository $repository) { 75 try { 76 return DifferentialGetWorkingCopy::getCleanMercurialWorkspace( 77 $repository); 78 } catch (Exception $e) { 79 throw new PhutilProxyException('Failed to allocate a workspace', $e); 80 } 81 } 82 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |