Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/controller/NuanceQueueEditController.php
| <?php | <?php | ||||
| final class NuanceQueueEditController extends NuanceController { | final class NuanceQueueEditController extends NuanceController { | ||||
| private $queueID; | public function handleRequest(AphrontRequest $request) { | ||||
| $viewer = $this->getViewer(); | |||||
| public function setQueueID($queue_id) { | $queue_id = $request->getURIData('id'); | ||||
| $this->queueID = $queue_id; | |||||
| return $this; | |||||
| } | |||||
| public function getQueueID() { | |||||
| return $this->queueID; | |||||
| } | |||||
| public function willProcessRequest(array $data) { | |||||
| $this->setQueueID(idx($data, 'id')); | |||||
| } | |||||
| public function processRequest() { | |||||
| $request = $this->getRequest(); | |||||
| $user = $request->getUser(); | |||||
| $queue_id = $this->getQueueID(); | |||||
| $is_new = !$queue_id; | $is_new = !$queue_id; | ||||
| if ($is_new) { | if ($is_new) { | ||||
| $queue = new NuanceQueue(); | $queue = NuanceQueue::initializeNewQueue(); | ||||
| } else { | } else { | ||||
| $queue = id(new NuanceQueueQuery()) | $queue = id(new NuanceQueueQuery()) | ||||
| ->setViewer($user) | ->setViewer($viewer) | ||||
| ->withIDs(array($queue_id)) | ->withIDs(array($queue_id)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| } | |||||
| if (!$queue) { | if (!$queue) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| } | |||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $title = 'TODO'; | $crumbs->addTextCrumb( | ||||
| pht('Queues'), | |||||
| $this->getApplicationURI('queue/')); | |||||
| if ($is_new) { | |||||
| $title = pht('Create Queue'); | |||||
| $crumbs->addTextCrumb(pht('Create')); | |||||
| } else { | |||||
| $title = pht('Edit %s', $queue->getName()); | |||||
| $crumbs->addTextCrumb($queue->getName(), $queue->getURI()); | |||||
| $crumbs->addTextCrumb(pht('Edit')); | |||||
| } | |||||
| return $this->buildApplicationPage( | return $this->buildApplicationPage( | ||||
| $crumbs, | $crumbs, | ||||
| array( | array( | ||||
| 'title' => $title, | 'title' => $title, | ||||
| )); | )); | ||||
| } | } | ||||
| } | } | ||||