コード例 #1
0
ファイル: Save.php プロジェクト: dextercowley/jissues
 /**
  * Execute the controller.
  *
  * @return  string
  *
  * @since   1.0
  */
 public function execute()
 {
     /* @type \JTracker\Application $app */
     $app = $this->getContainer()->get('app');
     $app->getUser()->authorize('manage');
     $project = $app->getProject();
     try {
         $this->model->setProject($project);
         $data = $app->input->get('category', array(), 'array');
         if (isset($data['id'])) {
             $this->model->save($data);
         } else {
             $this->model->add($data);
         }
         // Reload the project.
         $this->model->setProject($project);
         $app->enqueueMessage('The changes have been saved.', 'success');
         $app->redirect($app->get('uri.base.path') . 'category/' . $project->alias);
     } catch (\Exception $exception) {
         $app->enqueueMessage($exception->getMessage(), 'error');
         if ($app->input->get('id')) {
             $app->redirect($app->get('uri.base.path') . 'category/' . $project->alias . '/' . $app->input->get('id') . '/edit');
         } else {
             $app->redirect($app->get('uri.base.path') . 'category/' . $project->alias . '/add');
         }
     }
     parent::execute();
 }