Example #1
0
 public function viewDigitalBookBySlugAction(Request $request, $slug)
 {
     $page = (int) $request->query->get('page', 1);
     $action = new GetDigitalBookBySlugAction($this->app);
     $getComment = new GetAllDigitalBookCommentBySlugAction($this->app);
     $getVote = new GetUserDigitalVoteAction($this->app);
     $getCountVote = new GetDigitalVoteCountAction($this->app);
     $data = $action->handle($slug);
     $vote = $getVote->handle($data['id']);
     $qb = $getComment->handle($data['id']);
     $countData = $getCountVote->handle($data['id']);
     $pagination = $this->app['dezull.dbal_paginator']->paginate($qb, $page, 5);
     return $this->app['twig']->render('viewDigitalBookBySlug.twig', ['data' => $data, 'categories' => GetAllCategoriesHelper::help(1), 'vote' => $vote, 'countData' => $countData, 'pagination' => $pagination]);
 }
Example #2
0
 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)]);
 }