src/Sulu/Bundle/ContactBundle/Contact/ContactManager.php
private function setAvatar(Contact $contact, $avatar)
    {
        $mediaEntity = null;
        if (is_array($avatar) && $this->getProperty($avatar, 'id')) {
            $mediaId = $this->getProperty($avatar, 'id');
            $mediaEntity = $this->mediaRepository->findMediaById($mediaId);

            if (!$mediaEntity) {
                throw new EntityNotFoundException($this->mediaRepository->getClassName(), $mediaId);
            }
        }
        $contact->setAvatar($mediaEntity);
    }
private function setAvatar(Contact $contact, $avatar)
    {
        $mediaEntity = null;
        if (is_array($avatar) && $this->getProperty($avatar, 'id')) {
            $mediaId = $this->getProperty($avatar, 'id');
            $mediaEntity = $this->mediaRepository->findMediaById($mediaId);

            if (!$mediaEntity) {
                throw new EntityNotFoundException($this->mediaRepository->getClassName(), $mediaId);
            }
        }
        $contact->setAvatar($mediaEntity);
    }
private function setAvatar ( Contact $ contact , $ avatar ) { $ mediaEntity = null ; if ( is_array ( $ avatar ) && $ this -> getProperty ( $ avatar , 'id' ) ) { $ mediaId = $ this -> getProperty ( $ avatar , 'id' ) ; $ mediaEntity = $ this -> mediaRepository -> findMediaById ( $ mediaId ) ; if ( ! $ mediaEntity ) { throw new EntityNotFoundException ( $ this -> mediaRepository -> getClassName ( ) , $ mediaId ) ; } } $ contact -> setAvatar ( $ mediaEntity ) ; }
Sets a media with a given id as the avatar of a given contact.

@param Contact $contact
@param array $avatar with id property

@throws EntityNotFoundException
Sets a media with a given id as the avatar of a given contact .