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);
    }