public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('title', 'text', ['constraints' => new Assert\NotBlank()])->add('category', 'choice', ['constraints' => new Assert\NotBlank(), 'choices' => GetAllCategoriesHelper::help()])->add('author', 'text', ['constraints' => new Assert\NotBlank()])->add('totalPage', 'integer', ['constraints' => new Assert\NotBlank()])->add('image', 'file', ['constraints' => new Assert\NotBlank()])->add('description', 'textarea', ['constraints' => new Assert\NotBlank()]); }
public function editDigitalBookBySlugAction(Request $request, $slug) { $getAction = new GetDigitalBookBySlugAction($this->app); $editAction = new EditDigitalBookAction($this->app); $data = $getAction->handle($slug); if ($request->getMethod() == "POST") { $bookTitle = $request->request->get('bookTitle'); $bookCategory = $request->request->get('bookCategory'); $bookAuthor = $request->request->get('bookAuthor'); $bookDescription = $request->request->get('bookDescription'); $bookImage = $request->files->get('bookImage'); $bookAttachment = $request->files->get('bookAttachment'); $totalPage = $request->request->get('totalPage'); $editAction->handle($data['id'], $bookImage, $bookAttachment, $bookTitle, $bookCategory, $bookAuthor, $totalPage, $bookDescription, $data['imagePath'], $data['attachmentPath']); return $this->app->redirect($request->headers->get('referer')); } return $this->app['twig']->render('admin/editDigitalBookBySlug.twig', ['data' => $data, 'requestCount' => GetBorrowRequestCountHelper::help(), 'countOfBorrowing' => GetCountOfBookInBorrowingHelper::help(), 'categories' => GetAllCategoriesHelper::help(2)]); }
public function getDigitalBookByCategoryAction(Request $request, $slug) { $page = (int) $request->query->get('page', 1); $action = new GetDigitalBookByCategoryAction($this->app); $categories = GetAllCategoriesHelper::help(1); $qb = $action->handle($slug); $pagination = $this->app['dezull.dbal_paginator']->paginate($qb, $page, 5); return $this->app['twig']->render('getDigitalBookByCategory.twig', ['pagination' => $pagination, 'categories' => $categories]); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('title', 'text', ['constraints' => new Assert\NotBlank()])->add('category', 'choice', ['constraints' => new Assert\NotBlank(), 'choices' => GetAllCategoriesHelper::help()])->add('author', 'text', ['constraints' => new Assert\NotBlank()])->add('description', 'textarea', ['constraints' => new Assert\NotBlank()])->add('totalPage', 'integer', ['constraints' => new Assert\NotBlank()])->add('image', 'file', ['constraints' => [new Assert\NotBlank(), new Assert\File(['mimeTypes' => ['image/jpeg', 'image/png'], 'mimeTypesMessage' => "Only JPG or PNG are allowed"])]])->add('attachment', 'file', ['constraints' => [new Assert\NotBlank(), new Assert\File(['mimeTypes' => ['application/pdf', 'application/x-pdf'], 'mimeTypesMessage' => 'Only PDF is allowed'])]]); }