Ejemplo n.º 1
0
 public function testBookUnpack()
 {
     $package = new BookPackage($this->createFixtureBook());
     $package->updateBookSlug();
     $package->setTmpFolderPath($this->bookTmpFolderPath);
     $package->setTemplateFolderPath($this->bookTemplateFolderPath);
     $package->setBooksFolderPath($this->bookPrivateBooksFolderPath);
     $package->createBootstrapFiles();
     $package->pack();
     $package->unpack();
     $this->assertEquals(true, file_exists($this->bookPrivateBooksFolderPath . $package->getBook()->getSlug() . '.etb'));
 }
 public function testPublish()
 {
     $package = new BookPackage($this->createFixtureBook());
     $package->setTmpFolderPath($this->bookTmpFolderPath);
     $package->setTemplateFolderPath($this->bookTemplateFolderPath);
     $package->setBooksFolderPath($this->bookPrivateBooksFolderPath);
     $package->updateBookSlug();
     $package->createBootstrapFiles();
     $publisher = new BookPublisher($package);
     $publisher->setPublishBooksFolderPath($this->bookPublishBooksFolderPath);
     $publisher->publish();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $entityManager = $this->getContainer()->get('doctrine')->getManager();
     $books = $entityManager->getRepository('eTextBookLoungeBundle:Book')->findAll();
     foreach ($books as $book) {
         $oldSlug = $book->getSlug();
         $package = new BookPackage($book);
         $package->setTmpFolderPath($this->getContainer()->getParameter('book_tmp_dir'));
         $package->setBooksFolderPath($this->getContainer()->getParameter('books_dir'));
         $package->setTemplateFolderPath($this->getContainer()->getParameter('book_template_dir'));
         $package->updateBookSlug();
         $package->unpack($this->getContainer()->getParameter('books_dir') . $oldSlug . '.etb');
         $package->pack();
         if ($book->getIsPublic()) {
             $package->setBooksFolderPath($this->getContainer()->getParameter('public_dir'));
             $package->updateBookSlug();
             $package->pack();
             $package->setTmpFolderPath($this->getContainer()->getParameter('public_dir'));
             $package->updateBookSlug();
             $package->unpack();
         }
         $entityManager->persist($book);
         echo $book->getTitle() . " - " . $oldSlug . " | " . $book->getSlug() . "\n";
     }
     $entityManager->flush();
 }
Ejemplo n.º 4
0
 /**
  * @Route("/book/update/module", name="book-update-module")
  */
 public function updateModule(Request $request)
 {
     $content = $request->get('content');
     $bookSlug = $request->get('book');
     $moduleSlug = $request->get('module');
     $indexTasks = $request->get('blocks');
     $book = $this->getDoctrine()->getManager()->getRepository('eTextBookLoungeBundle:Book')->findOneBySlug($bookSlug);
     $package = new BookPackage($book);
     $package->setTmpFolderPath($this->container->getParameter('book_tmp_dir'));
     $package->setBooksFolderPath($this->container->getParameter('books_dir'));
     $package->setTemplateFolderPath($this->container->getParameter('book_template_dir'));
     $package->updateBookSlug();
     $package->createBootstrapFiles();
     $package->updateModuleContent($moduleSlug, $content);
     $package->updateBookInfoSummary($moduleSlug, $indexTasks);
     $package->updateBookSummary();
     $package->pack();
     return new JsonResponse(array('status' => 'success'));
 }