/**
  * @Route("/manage/add", name="addPage")
  * @Template()
  * @param Request $request
  * @throws \Exception
  * @return Response
  */
 public function addAction(Request $request)
 {
     $page = new Pages();
     $page->setVersion('1.0');
     $page->setDate(new \DateTime());
     $form = $this->createForm(new AddForm(), $page);
     $form->handleRequest($request);
     $resultUl = null;
     if ($form->isSubmitted() && $form->isValid()) {
         $collector = new RemoteDataCollector($page->getSourceUrl());
         $response = $collector->collect();
         $parser = new HtmlParser();
         $response = $parser->parse($response);
         $page->setRawdata($response);
         $page->setPrice($response['priceNight']);
         $em = $this->getDoctrine()->getManager();
         $ds = DIRECTORY_SEPARATOR;
         $uploadPath = $this->get('kernel')->getRootDir() . $ds . '..' . $ds . 'web' . $ds . 'uploads' . $ds;
         $em->persist($page);
         $em->flush();
         $imagesFactory = new ImageFactory($em, $uploadPath);
         $imagesFactory->processImages($page);
         $resultUl = '/rooms/' . $page->getId();
     }
     return $this->render('manage/add-new.html.twig', array('form' => $form->createView(), 'url' => $resultUl));
 }