container->get('net15.payment.mode.manager')->getAll(); return $this->render('@Payment/Admin/paymentMode/payment.mode.list.html.twig', ['paymentModeList'=>$paymentModeList]); } /** * @param Request $request * @return Response */ public function newPaymentModeAction(Request $request) { //If there is a form submission, we create new payment method, if not returns the empty form if ($request->isMethod('POST')){ $dataArray = $request->request->all(); if ($this->isCsrfTokenValid('app_create_payment_mode', $dataArray['_csrf_token'])){ $paymentMod = $this->container->get('net15.payment.mode.manager')->create($dataArray); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($paymentMod != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('payment_mode.message.create.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('error', $translator->trans('payment_mode.message.create.error', [], 'messages', $locale)); } } return $this->render('@Payment/Admin/paymentMode/payment.mode.html.twig', [ 'route' => 'app_new_payment_mode', 'parameters' => [] ]); } /** * @param string $publicKey * @param Request $request * @return mixed */ public function editPaymentModeAction(string $publicKey, Request $request){ $paymentMode =$this->container->get('net15.payment.mode.manager')->getByPublicKey($publicKey); if ($request->isMethod('POST')){ $dataArray = $request->request->all(); if ($this->isCsrfTokenValid('app_create_payment_mode', $dataArray['_csrf_token'])){ $paymentMode = $this->container->get('net15.payment.mode.manager')->update($paymentMode, $dataArray); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($paymentMode != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('payment_mode.message.edit.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('error', $translator->trans('payment_mode.message.edit.error', [], 'messages', $locale)); } } return $this->render('@Payment/Admin/paymentMode/payment.mode.html.twig', [ 'route' => 'app_edit_payment_mode', 'parameters' => ['publicKey'=>$publicKey], 'paymentMode' => $paymentMode ]); } /** * @param $publicKey * @return mixed */ public function viewPaymentModeAction(string $publicKey){ $paymentMode = $this->container->get('net15.payment.mode.manager')->getByPublicKey($publicKey); return $this->render('@Payment/Admin/paymentMode/view.payment.mode.html.twig', ['paymentMode'=>$paymentMode]); } /** * @param string $publicKey * @param Request $request * @return mixed */ public function deletePaymentModeAction(string $publicKey, Request $request){ $paymentMode = $this->container->get('net15.payment.mode.manager')->delete($publicKey); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($paymentMode != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('payment_mode.message.delete.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('error', $translator->trans('payment_mode.message.delete.error', [], 'messages', $locale)); return $this->redirectToRoute('app_list_payments_modes'); } public function newGroupAction(string $publicKey, Request $request){ $paymentMode = $this->get('net15.payment.mode.manager')->getByPublicKey($publicKey); if ($this->isCsrfTokenValid('create_new_payment_group', $request->request->get('_csrf_token'))){ $paymentGroup = $this->get('net15.payment.group.manager')->createGroup($request->get('group-name'), $paymentMode); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($paymentGroup != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('group.message.create.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('errors', $translator->trans('group.message.create.error', [], 'messages', $locale)); } $paymentGroups = $this->get('net15.payment.group.manager')->getAll(); return $this->render('@Payment/Admin/paymentGroup/payment.group.html.twig', [ 'paymentMode' => $paymentMode, 'groups' => $paymentGroups ]); } public function addPaymentModeToGroupAction(string $publicKey, Request $request){ $paymentMode = $this->get('net15.payment.mode.manager')->getByPublicKey($publicKey); if ($this->isCsrfTokenValid('add_payment_mode_to_group', $request->request->get('_csrf_token'))){ $mode = $this->get('net15.payment.group.manager')->addGroupToPaymentMode($paymentMode, $request->request->all()); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($mode != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('group.message.add_payment_mode_to_group.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('error', $translator->trans('group.message.add_payment_mode_to_group.error', [], 'messages', $locale)); } return $this->redirectToRoute('app_new_payment_group',['publicKey'=>$publicKey]); } public function updateGroupAction(string $groupPK,string $paymentModePK,Request $request){ $paymentGroup = $this->get('net15.payment.group.manager')->getByPublicKey($groupPK); if (!$paymentGroup instanceof PaymentGroup) return null; if ($request->isMethod('POST')) { if ($this->isCsrfTokenValid('app_update_payment_group', $request->request->get('_csrf_token'))){ $group = $this->get('net15.payment.group.manager')->updatePaymentGroup($paymentGroup, $request->get('payment_group-name')); if (!$group instanceof PaymentGroup) return null; // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($group != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('group.message.edit.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('error', $translator->trans('group.message.edit.error', [], 'messages', $locale)); return $this->redirectToRoute('app_new_payment_group',['publicKey'=>$paymentModePK]); } } return $this->render('@Payment/Admin/paymentGroup/update.payment.group.html.twig', [ 'paymentGroup' => $paymentGroup, 'paymentModePK' => $paymentModePK ]); } public function removeGroupAction(string $groupPK, string $paymentModePK,Request $request){ $removeGroup = $this->get('net15.payment.group.manager')->deleteGroup($groupPK); // Message confirmation or error $locale = $this->get('request_stack')->getCurrentRequest()->getLocale(); $translator = $this->get('translator'); ($removeGroup != null) ? $request->getSession()->getFlashBag()->set('success', $translator->trans('group.message.delete.success', [], 'messages', $locale)) : $request->getSession()->getFlashBag()->set('errors', $translator->trans('group.message.delete.error', [], 'messages', $locale)); return $this->redirectToRoute('app_new_payment_group',['publicKey'=>$paymentModePK]); } }