Added basic book adding functionality
Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -10,6 +10,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\Book;
|
||||
use KekRozsak\FrontBundle\Entity\BookCopy;
|
||||
use KekRozsak\FrontBundle\Form\Type\BookType;
|
||||
|
||||
class BookController extends Controller
|
||||
{
|
||||
@@ -28,6 +29,32 @@ class BookController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/konyvtar/uj-konyv.html", name="KekRozsakFrontBundle_bookNew", options={"expose" = true})
|
||||
* @Template()
|
||||
*/
|
||||
public function newAction()
|
||||
{
|
||||
$book = new Book();
|
||||
$newBookForm = $this->createForm(new BookType(), $book);
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$newBookForm->bindRequest($request);
|
||||
if ($newBookForm->isValid()) {
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($book);
|
||||
$em->flush();
|
||||
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'form' => $newBookForm->createView(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/sugo/konyvtar-lista.html", name="KekRozsakFrontBundle_bookListHelp")
|
||||
* @Template()
|
||||
|
Reference in New Issue
Block a user