public function onAdminProductCategoryEditAfter() { $app = $this->app; $id = $app['request']->attributes->get('id'); $form = $app['form.factory']->createBuilder('admin_category')->getForm(); $CategoryContent = $app['category_content.repository.category_content']->find($id); if (is_null($CategoryContent)) { $CategoryContent = new \Plugin\CategoryContent\Entity\CategoryContent(); } $form->get('content')->setData($CategoryContent->getContent()); $form->handleRequest($app['request']); if ('POST' === $app['request']->getMethod()) { if ($form->isValid()) { $content = $form->get('content')->getData(); $Category = $app['eccube.repository.category']->find($id); $CategoryContent->setCategoryId($Category->getId())->setCategory($Category)->setContent($content); $app['orm.em']->persist($CategoryContent); $app['orm.em']->flush(); } } }