protected function setUsersIdsByEmailAddressId(Entity $entity, $emailAddressId, $addAssignedUser = false) { $user = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId($emailAddressId, 'User'); if ($user) { $entity->addLinkMultipleId('users', $user->id); if ($addAssignedUser) { $entity->addLinkMultipleId('assignedUsers', $user->id); } } }