/** * @param Request $request * @param string $id * * @return \Symfony\Component\HttpFoundation\Response */ public function deleteAction(Request $request, $id) { $data = $this->manager->find($id); // It should always be possible to delete a connector even if the adaptor itself does // not exist anymore. So unlike the new and edit actions this action will not throw a // not found exception when the adaptor does not exist. if (!$data) { return $this->redirect($this->generateUrl('integrated_channel_config_index')); // data is already gone } $form = $this->createDeleteForm($data); if ($request->isMethod('delete')) { $form->handleRequest($request); if ($form->get('actions')->getData() == 'cancel') { return $this->redirect($this->generateUrl('integrated_channel_config_index')); } if ($form->isValid()) { $this->manager->remove($data); if ($message = $this->getFlashMessage()) { $message->success(sprintf('The config %s is removed', $data->getName())); } return $this->redirect($this->generateUrl('integrated_channel_config_index')); } } return $this->render('IntegratedChannelBundle:Config:delete.html.twig', ['adapter' => $this->registry->hasAdapter($data->getAdapter()) ? $this->registry->getAdapter($data->getAdapter()) : null, 'data' => $data, 'form' => $form->createView()]); }