コード例 #1
0
ファイル: AjaxController.php プロジェクト: csbill/csbill
 /**
  * Renders a contact card.
  *
  * @param Request $request
  * @param Contact $contact
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function contactAction(Request $request, Contact $contact)
 {
     if ($request->isMethod('DELETE')) {
         $client = $contact->getClient();
         if (count($client->getContacts()) === 1) {
             return $this->json(['message' => $this->trans('client.contact.at_least_1')], 500);
         }
         $entityManager = $this->getEm();
         $entityManager->remove($contact);
         $entityManager->flush();
         return $this->json([]);
     }
     return $this->serializeResponse($contact);
 }
コード例 #2
0
ファイル: AjaxController.php プロジェクト: Codixis/CSBill
 /**
  * Deletes a contact.
  *
  * @param Contact $contact
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function deletecontactAction(Contact $contact)
 {
     $client = $contact->getClient();
     if (count($client->getContacts()) === 1) {
         return $this->json(['message' => $this->trans('client.contact.at_least_1')], 500);
     }
     $entityMnager = $this->getEm();
     $entityMnager->remove($contact);
     $entityMnager->flush();
     return $this->json(array('status' => 'success'));
 }