/**
  * @ParamConverter("book", class="AcmeSPAApiBundle:Book")
  */
 public function showAction(Book $book)
 {
     /* @var $seo \Sonata\SeoBundle\Seo\SeoPage */
     $seoPage = $this->get('sonata.seo.page');
     $seoPage->setTitle($book->getTitle())->addMeta('name', 'description', $book->getDescription())->addMeta('property', 'og:title', $book->getTitle())->addMeta('property', 'og:type', 'book')->addMeta('property', 'og:author', $book->getAuthorsAsString());
     return $this->render('AcmeSPAChaplinBundle::layout.html.twig', array('payload' => $book));
 }
Ejemplo n.º 2
0
 public function load(ObjectManager $manager)
 {
     $book = new Book();
     $book->setTitle('The Man in the High Castle')->setDescription('The story of The Man in the High Castle, about daily life under totalitarian Fascist imperialism, occurs in 1962, fifteen years after the end of a longer Second World War (1939–1947 in this history).')->addAuthor($this->getReference('dick'));
     $manager->persist($book);
     $book = new Book();
     $book->setTitle('The Martian Chronicles')->setDescription('The Martian Chronicles is a 1950 science fiction short story collection by Ray Bradbury that chronicles the colonization of Mars by humans fleeing from a troubled and eventually atomically devastated Earth, and the conflict between aboriginal Martians and the new colonists.')->addAuthor($this->getReference('bradbury'));
     $manager->persist($book);
     $book = new Book();
     $book->setTitle('The Hitchhiker\'s Guide to the Galaxy')->setDescription("The Hitchhiker's Guide to the Galaxy is the first of five books in the Hitchhiker's Guide to the Galaxy comedy science fiction \"trilogy\" by Douglas Adams (with the sixth written by Eoin Colfer).")->addAuthor($this->getReference('adams'));
     $manager->persist($book);
     $manager->flush();
 }
Ejemplo n.º 3
0
 /**
  * @param Book $book
  * @return \Symfony\Component\HttpFoundation\Response|\FOS\RestBundle\View\View
  */
 protected function processForm(Book $book)
 {
     $statusCode = $book->getId() > 0 ? 204 : 201;
     $form = $this->formFactory->create(new BookType(), $book);
     $form->bind($this->request);
     if ($form->isValid()) {
         $em = $this->doctrine->getEntityManager();
         $em->persist($book);
         $em->flush();
         $response = new Response();
         $response->setContent($this->serializer->serialize($book, 'json'));
         $response->setStatusCode($statusCode);
         return $response;
     }
     return View::create($form, 400);
 }