Differential D14700 Diff 35556 src/applications/transactions/controller/PhabricatorEditEngineController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/controller/PhabricatorEditEngineController.php
Show All 29 Lines | if ($engine_key !== null) { | ||||
"/transactions/editengine/{$engine_key}/"); | "/transactions/editengine/{$engine_key}/"); | ||||
} | } | ||||
} | } | ||||
return $crumbs; | return $crumbs; | ||||
} | } | ||||
protected function loadConfigForEdit() { | protected function loadConfigForEdit() { | ||||
return $this->loadConfig($need_edit = true); | |||||
} | |||||
protected function loadConfigForView() { | |||||
return $this->loadConfig($need_edit = false); | |||||
} | |||||
private function loadConfig($need_edit) { | |||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$engine_key = $request->getURIData('engineKey'); | $engine_key = $request->getURIData('engineKey'); | ||||
$this->setEngineKey($engine_key); | $this->setEngineKey($engine_key); | ||||
$key = $request->getURIData('key'); | $key = $request->getURIData('key'); | ||||
if ($need_edit) { | |||||
$capabilities = array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
); | |||||
} else { | |||||
$capabilities = array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
); | |||||
} | |||||
$config = id(new PhabricatorEditEngineConfigurationQuery()) | $config = id(new PhabricatorEditEngineConfigurationQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withEngineKeys(array($engine_key)) | ->withEngineKeys(array($engine_key)) | ||||
->withIdentifiers(array($key)) | ->withIdentifiers(array($key)) | ||||
->requireCapabilities( | ->requireCapabilities($capabilities) | ||||
array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
PhabricatorPolicyCapability::CAN_EDIT, | |||||
)) | |||||
->executeOne(); | ->executeOne(); | ||||
if ($config) { | if ($config) { | ||||
$engine = $config->getEngine(); | $engine = $config->getEngine(); | ||||
// TODO: When we're editing the meta-engine, we need to set the engine | // TODO: When we're editing the meta-engine, we need to set the engine | ||||
// itself as its own target. This is hacky and it would be nice to find | // itself as its own target. This is hacky and it would be nice to find | ||||
// a cleaner approach later. | // a cleaner approach later. | ||||
if ($engine instanceof PhabricatorEditEngineConfigurationEditEngine) { | if ($engine instanceof PhabricatorEditEngineConfigurationEditEngine) { | ||||
$engine->setTargetEngine($engine); | $engine->setTargetEngine($engine); | ||||
} | } | ||||
} | } | ||||
return $config; | return $config; | ||||
} | } | ||||
} | } |