protected function showApi() { $paths = $this->router->getMatchedRoute()->getPaths(); $endpoint = $paths['action']; $appoption = new Appoptions(); $option = $appoption->findFirst(array("conditions" => "version = 1 AND endpoint = :endpoint:", "bind" => array('endpoint' => $endpoint))); if ($option) { return $this->response->setContent($option->data); } else { throw new Exception\ResourceNotFoundException('Request resource not found'); } }
/** * @operationName("编辑App资源") * @operationDescription("编辑App资源") */ public function editAction() { $this->view->changeRender('admin/appoption/create'); $form = new \Wscn\Forms\AppoptionForm(); $appoption = Entities\Appoptions::findFirst($this->dispatcher->getParam('id')); $form->setModel($appoption ? $appoption : new Entities\Appoptions()); $this->view->setVar('form', $form); $this->view->setVar('item', $appoption); if (!$this->request->isPost()) { return false; } $form->bind($this->request->getPost(), $appoption); if (!$form->isValid()) { return $this->showInvalidMessages($form); } $appoption = $form->getEntity(); $appoption->assign($this->request->getPost()); try { $appoption->save(); } catch (\Exception $e) { return $this->showException($e, $appoption->getMessages()); } $this->flashSession->success('SUCCESS_APPOPTIONS_UPDATED'); return $this->redirectHandler('/admin/appoption/edit/' . $appoption->id); }