public function saveAction(Request $request, Application $app)
 {
     $goods = new Goods();
     $goodsClass = $app['repository.goodsClass']->findAll();
     foreach ($goodsClass as $val) {
         $goodsClassValue[] = $val['id'];
         $goodsClassName[] = $val['title'];
     }
     $goods->setGoodsClassValue($goodsClassValue);
     $goods->setGoodsClassName($goodsClassName);
     $form = $app['form.factory']->create(new SaveGoodsType(), $goods);
     $form->handleRequest($request);
     if ($request->isMethod('POST')) {
         //            $form->bind($request);
         if ($form->isValid()) {
             $goods->setStatus(0);
             $goods->setCreatedTime(time());
             $resultSave = $app['repository.goods']->save($goods);
             if ($resultSave) {
                 $msg = '添加成功。';
                 $url = '/admin/saveGoods';
                 CommonFunc::alertHref($msg, $url);
                 return;
             } else {
                 $msg = '添加失败,请重试。';
                 CommonFunc::alertBack($msg);
                 return;
             }
         }
     }
     $data = array('form' => $form->createView(), 'title' => '添加资源');
     return $app['twig']->render('admin/saveGoods.html.twig', $data);
 }