コード例 #1
0
 public function onAdminProductCategoryEditAfter()
 {
     $app = $this->app;
     if ('POST' !== $app['request']->getMethod()) {
         return;
     }
     $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();
     }
     if ('POST' === $app['request']->getMethod()) {
         $form->handleRequest($app['request']);
         if ($form->isValid()) {
             $CategoryContent->setId($id)->setContent($form['content']->getData());
             $app['orm.em']->persist($CategoryContent);
             $app['orm.em']->flush();
         }
     }
 }