/** * @Route() * @Method("GET") * * @param Todo $todo * @return RedirectResponse */ public function indexAction(Todo $todo) { try { $this->completeTodo->run($todo); $this->notification->info('タスクを完了にしました'); } catch (\InvalidArgumentException $e) { $this->notification->danger('完了処理に失敗しました'); } return new RedirectResponse($this->router->generate('app_todo_default_index')); }
/** * @Route() * @Method("POST") * * @param Request $request * @return RedirectResponse */ public function saveAction(Request $request) { $form = $this->formFactory->create('todo'); $form->handleRequest($request); if ($form->isValid()) { $this->addTodo->run($form->getData()); $this->notification->info('タスクを登録しました'); } else { $this->notification->danger('タスクの登録に失敗しました'); } return new RedirectResponse($this->router->generate('app_todo_default_index')); }