コード例 #1
0
 public function process(WeeklyChallenge $challenge)
 {
     $new = NULL === $challenge->getId() ? true : false;
     $validator = $this->validator;
     $errors = $validator->validate($challenge);
     if (count($errors) > 0) {
         return $this->view($errors, 400);
     } else {
         $this->em->persist($challenge);
         try {
             $this->em->flush();
         } catch (DBALException $e) {
             //print_r($e->getMessage());die('foo');
             //return $this->view($e->getMessage(), 400);
             $this->logger->info("Can not save challenge:  " . $e->getMessage(), get_defined_vars());
         }
     }
 }
コード例 #2
0
 protected function process(WeeklyChallenge $challenge)
 {
     $new = NULL === $challenge->getId() ? true : false;
     $validator = $this->get('validator');
     $errors = $validator->validate($challenge);
     if (count($errors) > 0) {
         return $this->view($errors, 400);
     } else {
         $em = $this->getDoctrine()->getManager();
         $em->persist($challenge);
         try {
             $em->flush();
         } catch (DBALException $e) {
             //print_r($e->getMessage());die('foo');
             return $this->view($e->getMessage(), 400);
         }
     }
 }