Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionController.php
<?php | <?php | ||||
abstract class DiffusionController extends PhabricatorController { | abstract class DiffusionController extends PhabricatorController { | ||||
protected $diffusionRequest; | private $diffusionRequest; | ||||
public function setDiffusionRequest(DiffusionRequest $request) { | |||||
$this->diffusionRequest = $request; | |||||
return $this; | |||||
} | |||||
protected function getDiffusionRequest() { | protected function getDiffusionRequest() { | ||||
if (!$this->diffusionRequest) { | if (!$this->diffusionRequest) { | ||||
throw new Exception(pht('No Diffusion request object!')); | throw new PhutilInvalidStateException('loadDiffusionContext'); | ||||
} | } | ||||
return $this->diffusionRequest; | return $this->diffusionRequest; | ||||
} | } | ||||
protected function hasDiffusionRequest() { | |||||
return (bool)$this->diffusionRequest; | |||||
} | |||||
public function willBeginExecution() { | public function willBeginExecution() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
// Check if this is a VCS request, e.g. from "git clone", "hg clone", or | // Check if this is a VCS request, e.g. from "git clone", "hg clone", or | ||||
// "svn checkout". If it is, we jump off into repository serving code to | // "svn checkout". If it is, we jump off into repository serving code to | ||||
// process the request. | // process the request. | ||||
if (DiffusionServeController::isVCSRequest($request)) { | |||||
$serve_controller = id(new DiffusionServeController()) | $serve_controller = new DiffusionServeController(); | ||||
->setCurrentApplication($this->getCurrentApplication()); | if ($serve_controller->isVCSRequest($request)) { | ||||
return $this->delegateToController($serve_controller); | return $this->delegateToController($serve_controller); | ||||
} | } | ||||
return parent::willBeginExecution(); | return parent::willBeginExecution(); | ||||
} | } | ||||
protected function shouldLoadDiffusionRequest() { | |||||
return true; | |||||
} | |||||
public function handleRequest(AphrontRequest $request) { | |||||
if ($request->getURIData('callsign') && | |||||
$this->shouldLoadDiffusionRequest()) { | |||||
try { | |||||
$drequest = DiffusionRequest::newFromAphrontRequestDictionary( | |||||
$request->getURIMap(), | |||||
$request); | |||||
} catch (Exception $ex) { | |||||
return id(new Aphront404Response()) | |||||
->setRequest($request); | |||||
} | |||||
$this->setDiffusionRequest($drequest); | |||||
} | |||||
return $this->processDiffusionRequest($request); | |||||
} | |||||
protected function loadDiffusionContextForEdit() { | protected function loadDiffusionContextForEdit() { | ||||
return $this->loadContext( | return $this->loadContext( | ||||
array( | array( | ||||
'edit' => true, | 'edit' => true, | ||||
)); | )); | ||||
} | } | ||||
protected function loadDiffusionContext() { | protected function loadDiffusionContext() { | ||||
Show All 35 Lines | abstract class DiffusionController extends PhabricatorController { | ||||
protected function getRepositoryIdentifierFromRequest( | protected function getRepositoryIdentifierFromRequest( | ||||
AphrontRequest $request) { | AphrontRequest $request) { | ||||
$identifier = $request->getURIData('repositoryCallsign'); | $identifier = $request->getURIData('repositoryCallsign'); | ||||
if (strlen($identifier)) { | if (strlen($identifier)) { | ||||
return $identifier; | return $identifier; | ||||
} | } | ||||
return (int)$request->getURIData('repositoryID'); | $id = $request->getURIData('repositoryID'); | ||||
if (strlen($id)) { | |||||
return (int)$id; | |||||
} | } | ||||
protected function processDiffusionRequest(AphrontRequest $request) { | return null; | ||||
throw new PhutilMethodNotImplementedException(); | |||||
} | } | ||||
public function buildCrumbs(array $spec = array()) { | public function buildCrumbs(array $spec = array()) { | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumb_list = $this->buildCrumbList($spec); | $crumb_list = $this->buildCrumbList($spec); | ||||
foreach ($crumb_list as $crumb) { | foreach ($crumb_list as $crumb) { | ||||
$crumbs->addCrumb($crumb); | $crumbs->addCrumb($crumb); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |