/** * @Route("/ajax-list", name="project_milestone_status_rule_ajax_list") */ public function ajaxListAction(Request $request) { $routes = $this->dataRoutes()->link('info_link', $this->crudInfo->getInfoPage(), ['id' => '::id', 'slug' => $this->getSlug()])->link('edit_link', $this->crudInfo->getEditPage(), ['id' => '::id', 'slug' => $this->getSlug()])->link('remove_link', $this->crudInfo->getRemovePage(), ['id' => '::id', 'slug' => $this->getSlug()]); $repository = $this->crudInfo->getRepository(); $dataTable = $repository->createDataTable(); $dataTable->process($request); return new JsonResponse($routes->process($repository->listData($dataTable, $this->getTranslator()))); }
/** * @Route("/ajax-list", name="project_territory_ajax_list") */ public function ajaxListAction(Request $request) { $routes = $this->dataRoutes()->link('info_link', 'project_territory_info', ['id' => '::id', 'slug' => $this->getSlug()])->link('edit_link', 'project_territory_edit', ['id' => '::id', 'slug' => $this->getSlug()])->link('remove_link', 'project_territory_remove', ['id' => '::id', 'slug' => $this->getSlug()]); $repository = $this->crudInfo->getRepository(); $dataTable = $repository->createDataTable(); $dataTable->process($request); return new JsonResponse($routes->process($repository->listData($dataTable))); }
public function performAjaxList(AreaFilter $filter, Request $request) { $routes = $this->dataRoutes(); $routes->link('info_link', $this->crudInfo->getInfoPage(), ['id' => '::id', 'slug' => $this->getSlug()]); $filterForm = $filter->createForm($this->createFormBuilder($filter)); $filterForm->handleRequest($request); $repository = $this->crudInfo->getRepository(); $dataTable = $repository->createDataTable(); $dataTable->filter($filter); $dataTable->process($request); return new JsonResponse($routes->process($repository->listData($dataTable))); }
/** * @Route("/{id}/upload-test", name="project_course_upload_test") */ public function uploadTestAction($id, Request $request) { try { $repository = $this->crudInfo->getRepository(); $item = $repository->getItem($id); $form = $this->createForm(CourseTestUploadForm::class); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); if (!$data['file'] instanceof UploadedFile) { return $this->showPageWithError($this->trans('An error occurred during uploading the test questions.'), $this->crudInfo->getInfoPage(), array('id' => $id, 'slug' => $this->getSlug())); } if ($data['file']->getMimeType() != 'application/xml') { return $this->showPageWithError($this->trans('Please upload an XML file!'), $this->crudInfo->getInfoPage(), array('id' => $id, 'slug' => $this->getSlug())); } $content = file_get_contents($data['file']->getRealPath()); $item->createTest($content); $this->verifyFileCorrectness($item->getTest()); $repository->saveTest($item); return $this->showPageWithMessage($this->trans('The course test questions have been uploaded correctly.'), $this->crudInfo->getInfoPage(), array('id' => $id, 'slug' => $this->getSlug())); } $this->breadcrumbs()->link($item->getName(), 'project_course_info', ['id' => $item->getId(), 'slug' => $this->getSlug()])->link($this->trans('Upload test'), 'project_course_upload_test', ['id' => $item->getId(), 'slug' => $this->getSlug()]); return $this->render($this->crudInfo->getTemplateLocation() . 'upload-test.html.twig', array('pageTitle' => $this->crudInfo->getPageTitle(), 'pageSubtitle' => $this->crudInfo->getPageSubtitle(), 'item' => $item, 'form' => $form->createView())); } catch (ItemNotFoundException $exception) { return $this->showPageWithError($this->crudInfo->getItemNotFoundErrorMessage(), $this->crudInfo->getIndexPage()); } catch (ModelException $exception) { return $this->showPageWithError($this->trans($exception->getMessage()), $this->crudInfo->getIndexPage()); } }
/** * @Route("/{id}/duplicate", name="area_edk_message_duplicate") */ public function duplicateAction($id) { try { $item = $this->crudInfo->getRepository()->getItem($id); $this->crudInfo->getRepository()->changeDuplicateFlag($item); return $this->showPageWithMessage($this->trans('MsgDuplicateStatusChanged', [], 'edk'), 'area_edk_message_info', ['slug' => $this->getSlug(), 'id' => $item->getId()]); } catch (ModelException $ex) { return $this->showPageWithError($this->trans($ex->getMessage(), [], 'edk'), 'area_edk_message_index', ['slug' => $this->getSlug()]); } }