/** * @param PersonInterface $user * @param string $scope * @return bool */ private function checkScope(PersonInterface $user, $scope) { // 'id_cards', 'addresses' switch ($scope) { case 'name': case 'full_name': case 'surname': $value = $user->getFullName(); return $value && strlen($value) > 0 && strlen($user->getSurname()) > 0; break; case 'mobile': case 'phone_number': $value = $user->getMobile(); break; case 'country': return $user->getCountry() instanceof Country; case 'state': return $user->getState() instanceof State; case 'city': return $user->getCity() instanceof City; case 'birthdate': return $user->getBirthdate() instanceof \DateTime; case 'email': case 'email_verified': return $user->getEmailConfirmedAt() instanceof \DateTime; case 'cpf': $cpf = $user->getCpf(); return $cpf && CPFValidator::isCPFValid($cpf); default: return true; } return $value && strlen($value) > 0; }
private function resendEmailConfirmation(PersonInterface $person) { $mailer = $this->get('fos_user.mailer'); if (is_null($person->getEmailConfirmedAt())) { if (is_null($person->getConfirmationToken())) { $tokenGenerator = new TokenGenerator(); $person->setConfirmationToken($tokenGenerator->generateToken()); $userManager = $this->get('fos_user.user_manager'); $userManager->updateUser($person); } $mailer->sendConfirmationEmailMessage($person); $this->flashEmailSent(); return $this->redirectToRoute('task_confirm_email'); } }