Differential D14001 Diff 33860 src/applications/releeph/controller/request/ReleephRequestEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/releeph/controller/request/ReleephRequestEditController.php
| <?php | <?php | ||||
| final class ReleephRequestEditController extends ReleephBranchController { | final class ReleephRequestEditController extends ReleephBranchController { | ||||
| private $requestID; | public function handleRequest(AphrontRequest $request) { | ||||
| private $branchID; | $action = $request->getURIData('action'); | ||||
| $request_id = $request->getURIData('requestID'); | |||||
| $branch_id = $request->getURIData('branchID'); | |||||
| $viewer = $request->getViewer(); | |||||
| public function willProcessRequest(array $data) { | if ($request_id) { | ||||
| $this->requestID = idx($data, 'requestID'); | |||||
| $this->branchID = idx($data, 'branchID'); | |||||
| } | |||||
| public function processRequest() { | |||||
| $request = $this->getRequest(); | |||||
| $viewer = $request->getUser(); | |||||
| if ($this->requestID) { | |||||
| $pull = id(new ReleephRequestQuery()) | $pull = id(new ReleephRequestQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withIDs(array($this->requestID)) | ->withIDs(array($request_id)) | ||||
| ->requireCapabilities( | ->requireCapabilities( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| )) | )) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$pull) { | if (!$pull) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $branch = $pull->getBranch(); | $branch = $pull->getBranch(); | ||||
| $is_edit = true; | $is_edit = true; | ||||
| } else { | } else { | ||||
| $branch = id(new ReleephBranchQuery()) | $branch = id(new ReleephBranchQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withIDs(array($this->branchID)) | ->withIDs(array($branch_id)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$branch) { | if (!$branch) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $pull = id(new ReleephRequest()) | $pull = id(new ReleephRequest()) | ||||
| ->setRequestUserPHID($viewer->getPHID()) | ->setRequestUserPHID($viewer->getPHID()) | ||||
| ->setBranchID($branch->getID()) | ->setBranchID($branch->getID()) | ||||
| Show All 26 Lines | foreach ($field_list->getFields() as $field) { | ||||
| $field | $field | ||||
| ->setReleephProject($product) | ->setReleephProject($product) | ||||
| ->setReleephBranch($branch) | ->setReleephBranch($branch) | ||||
| ->setReleephRequest($pull); | ->setReleephRequest($pull); | ||||
| } | } | ||||
| $field_list->readFieldsFromStorage($pull); | $field_list->readFieldsFromStorage($pull); | ||||
| if ($this->branchID) { | if ($branch_id) { | ||||
| $cancel_uri = $this->getApplicationURI('branch/'.$this->branchID.'/'); | $cancel_uri = $this->getApplicationURI('branch/'.$branch_id.'/'); | ||||
| } else { | } else { | ||||
| $cancel_uri = '/'.$pull->getMonogram(); | $cancel_uri = '/'.$pull->getMonogram(); | ||||
| } | } | ||||
| // Make edits | // Make edits | ||||
| $errors = array(); | $errors = array(); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $xactions = array(); | $xactions = array(); | ||||
| ▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines | |||||