protected function addPhone($contact, $phoneData)
{
$success = true;
$phoneType = $this->em->getRepository(self::$phoneTypeEntityName)->find($phoneData['phoneType']['id']);
if (isset($phoneData['id'])) {
throw new EntityIdAlreadySetException(self::$phoneEntityName, $phoneData['id']);
} elseif (!$phoneType) {
throw new EntityNotFoundException(self::$phoneTypeEntityName, $phoneData['phoneType']['id']);
} else {
$phone = new Phone();
$phone->setPhone($phoneData['phone']);
$phone->setPhoneType($phoneType);
$this->em->persist($phone);
$contact->addPhone($phone);
}
return $success;
}