Sulu\Bundle\ContactBundle\Contact\AbstractContactManager::addPhone PHP Méthode

addPhone() protected méthode

Add a new phone to the given contact and persist it with the given object manager.
protected addPhone ( $contact, array $phoneData ) : boolean
$contact
$phoneData array
Résultat boolean True if there was no error, otherwise false
    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;
    }