src/PHPDish/Bundle/PostBundle/Controller/CategoryController.php
public function editAction($slug, Request $request)
    {
        $manager = $this->getCategoryManager();
        $category = $manager->findCategoryBySlug($slug);
        if (!$category) {
            throw $this->createNotFoundException();
        }
        $this->denyAccessUnlessGranted('edit', $category);
        $form = $this->createForm(CategoryType::class, $category);
        $form->handleRequest($request);
        if ($form->isValid() && $form->isSubmitted()) {
            $manager->saveCategory($category);
            $this->addFlash('success', $this->get('translator')->trans('category.edit_success'));

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

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

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

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

@Route("/categories/{slug}/edit", name="category_edit")

@param string  $slug
@param Request $request

@return Response