protected function buildCardKey($cardKeyData)
 {
     $cardKey = new CardKey();
     $cardKey->setCardKey($cardKeyData['cardKey']);
     $cardKey->setCardKeyClassId($cardKeyData['cardKeyClassId']);
     $cardKey->setStatus($cardKeyData['status']);
     $cardKey->setCreatedTime($cardKeyData['createdTime']);
     return $cardKey;
 }
 public function createCardKeyAjaxAction(Request $request, Application $app)
 {
     $cardKeyClassId = $request->query->get('cardKeyClassId');
     $cardKeyNum = $request->query->get('cardKeyNum');
     $cardKeyArray = array();
     for ($i = 0; $i <= $cardKeyNum; $i++) {
         $cardKey = new CardKey();
         $cardKey->setCardKey(md5($i . $app['cardKeyMD5Key'] . time()));
         $cardKey->setCardKeyClassId($cardKeyClassId);
         $cardKey->setStatus(0);
         $cardKey->setCreatedTime(time());
         $app['repository.cardKey']->save($cardKey);
         array_push($cardKeyArray, $cardKey->getCardKey());
     }
     $data = array('result' => 1, 'cardKeyArray' => $cardKeyArray);
     return JsonResponse::create($data);
 }