我想同时从我的数据库和对讲机中删除一个用户,但我想检查该用户是否存在于对讲机中:
public function deleteUserAction(Request $request, $id)
{
$doctrine = $this->getDoctrine();
$em = $doctrine->getManager();
$intercom = IntercomBasicAuthClient::factory(array(
'app_id' => 'xxxxxx',
'api_key' => 'xxxxxxxxxxxx'
));
$user = $doctrine->getRepository('ZaidUserBundle:User')->find($id);
if($user) {
//delete user from intercom
//I want some condition here
$intercom->deleteUser(array("email" => $user->getEmail()));
//delete user from database
$em->remove($user);
$em->flush();
}
return new Response(200);
}