src/PHPDish/Bundle/PostBundle/Controller/BookController.php
public function editAction($slug, Request $request)
    {
        $manager = $this->getBookManager();
        $book = $manager->findBook($slug);
        if (!$book) {
            throw $this->createNotFoundException();
        }
        $this->denyAccessUnlessGranted('edit', $book);
        $form = $this->createForm(BookType::class, $book);
        $form->handleRequest($request);
        if ($form->isValid() && $form->isSubmitted()) {
            $manager->saveBook($book);
            $this->addFlash('success', $this->get('translator')->trans('book.edit_success'));

            return $this->redirectToRoute('book_view', [
                'slug' => $book->getSlug(),
            ]);
        }

        return $this->render($this->configuration->getTemplate('Category:create.html.twig'), [
            'form' => $form->createView(),
            'category' => $book,
            'hasManyCategories' => false,
            'isBook' => true
        ]);
    }
public function editAction($slug, Request $request)
    {
        $manager = $this->getBookManager();
        $book = $manager->findBook($slug);
        if (!$book) {
            throw $this->createNotFoundException();
        }
        $this->denyAccessUnlessGranted('edit', $book);
        $form = $this->createForm(BookType::class, $book);
        $form->handleRequest($request);
        if ($form->isValid() && $form->isSubmitted()) {
            $manager->saveBook($book);
            $this->addFlash('success', $this->get('translator')->trans('book.edit_success'));

            return $this->redirectToRoute('book_view', [
                'slug' => $book->getSlug(),
            ]);
        }

        return $this->render($this->configuration->getTemplate('Category:create.html.twig'), [
            'form' => $form->createView(),
            'category' => $book,
            'hasManyCategories' => false,
            'isBook' => true
        ]);
    }
编辑电子书信息.

@Route("/books/{slug}/edit", name="book_edit")

@param string  $slug
@param Request $request

@return Response