protected function performInsert(Request $request) { $entity = new EdkRoute(); $action = new InsertAction($this->crudInfo, $entity, EdkRouteForm::class, ['mode' => EdkRouteForm::ADD, 'areaRepository' => $this->findAreaRepository()]); $action->slug($this->getSlug()); $action->set('isArea', $this->isArea()); return $action->run($this, $request); }
/** * @Route("/insert", name="area_edk_participant_insert") */ public function insertAction(Request $request) { try { $area = $this->getMembership()->getItem(); $project = $area->getProject(); $settingsRepository = $this->get('wio.edk.repo.registration'); $settingsRepository->setRootEntity($area); $entity = EdkParticipant::newParticipant(); if ($request->getMethod() == 'POST') { $entity->setRegistrationSettings($settingsRepository->getItem($request->get('route', null))); $entity->setIpAddress(ip2long($_SERVER['REMOTE_ADDR'])); } $action = new InsertAction($this->crudInfo, $entity); $action->slug($this->getSlug()); $action->form(function ($controller, $item, $formType, $action) use($request, $project, $settingsRepository) { $form = new EdkParticipantForm(EdkParticipantForm::ADD, null, $settingsRepository); $form->setText(1, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS1_TEXT, $request, $project)); $form->setText(2, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS2_TEXT, $request, $project)); $form->setText(3, $this->getTextRepository()->getText(EdkTexts::REGISTRATION_TERMS3_TEXT, $request, $project)); return $controller->createForm($form, $item, array('action' => $action)); }); $action->set('ajaxRoutePage', 'area_edk_participant_ajax_routes'); return $action->run($this, $request); } catch (ItemNotFoundException $exception) { return $this->showPageWithError($this->trans($exception->getMessage(), [], 'edk'), 'area_edk_participant_index', ['slug' => $this->getSlug()]); } }