/** * Ajax handler for removing a Doctor from InstitutionMedicalCenter * Expected parameters: * - imcId * - doctorId * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function removeDoctorAction(Request $request) { $result = array('status' => false); $doctor = $this->getDoctrine()->getRepository('DoctorBundle:Doctor')->find($request->get('doctorId', 0)); if (!$doctor) { $result['message'] = 'Invalid Doctor Id.'; } try { $this->institutionMedicalCenter->removeDoctor($doctor); $this->service->save($this->institutionMedicalCenter); $result['status'] = true; $result['message'] = 'Doctor successfully removed from your clinic.'; // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); // Invalidate InstitutionProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionProfileKey($this->institutionMedicalCenter->getInstitution()->getId())); } catch (\Exception $e) { } return new Response(\json_encode($result), 200, array('content-type' => 'application/json')); }