Exemple #1
0
 /**
  * Build a zip of downloaded documents
  *
  * @param Application $app
  * @param Request     $request
  * @param Token       $token
  *
  * @return Response
  */
 public function downloadExecute(Application $app, Request $request, Token $token)
 {
     if (false === ($list = @unserialize($token->getData()))) {
         return $app->json(['success' => false, 'message' => 'Invalid datas']);
     }
     set_time_limit(0);
     // Force the session to be saved and closed.
     $app['session']->save();
     ignore_user_abort(true);
     \set_export::build_zip($app, $token, $list, sprintf($app['tmp.download.path'] . '/%s.zip', $token->getValue()));
     return $app->json(['success' => true, 'message' => '']);
 }
 /**
  * Build a zip of downloaded documents
  *
  * @param Token       $token
  *
  * @return Response
  */
 public function downloadExecute(Token $token)
 {
     if (false === ($list = @unserialize($token->getData()))) {
         return $this->app->json(['success' => false, 'message' => 'Invalid datas']);
     }
     set_time_limit(0);
     // Force the session to be saved and closed.
     /** @var Session $session */
     $session = $this->app['session'];
     $session->save();
     ignore_user_abort(true);
     if ($list['count'] > 1) {
         \set_export::build_zip($this->app, $token, $list, sprintf($this->app['tmp.download.path'] . '/%s.zip', $token->getValue()));
     } else {
         $list['complete'] = true;
         $token->setData(serialize($list));
         /** @var EntityManagerInterface $manager */
         $manager = $this->app['orm.em'];
         $manager->persist($token);
         $manager->flush();
     }
     return $this->app->json(['success' => true, 'message' => '']);
 }