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();
 }
 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'));
 }