本文整理汇总了PHP中Claroline\CoreBundle\Entity\User::setIsMailNotified方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setIsMailNotified方法的具体用法?PHP User::setIsMailNotified怎么用?PHP User::setIsMailNotified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::setIsMailNotified方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setIsMailNotified
public function setIsMailNotified(User $user, $isNotified)
{
$user->setIsMailNotified($isNotified);
$this->objectManager->persist($user);
$this->objectManager->flush();
}
示例2: importUsers
//.........这里部分代码省略.........
}
$userEntity = $this->userRepo->findOneByMail($email);
if (!$userEntity) {
$userEntity = $this->userRepo->findOneByUsername($username);
if (!$userEntity && $code !== null) {
//the code isn't required afaik
$userEntity = $this->userRepo->findOneByAdministrativeCode($code);
}
}
if ($userEntity && $options['ignore-update']) {
if ($logger) {
$logger(" Skipping {$userEntity->getUsername()}...");
}
continue;
}
$isNew = false;
if (!$userEntity) {
$isNew = true;
$userEntity = new User();
$userEntity->setPlainPassword($pwd);
++$countCreated;
} else {
if (!empty($pwd)) {
$userEntity->setPlainPassword($pwd);
}
++$countUpdated;
}
$userEntity->setUsername($username);
$userEntity->setMail($email);
$userEntity->setFirstName($firstName);
$userEntity->setLastName($lastName);
$userEntity->setAdministrativeCode($code);
$userEntity->setPhone($phone);
$userEntity->setLocale($lg);
$userEntity->setAuthentication($authentication);
$userEntity->setIsMailNotified($isMailNotified);
$userEntity->setIsMailValidated($isMailValidated);
if ($options['single-validate']) {
$errors = $this->validator->validate($userEntity);
if (count($errors) > 0) {
$skipped[$i] = $userEntity;
if ($isNew) {
--$countCreated;
} else {
--$countUpdated;
}
continue;
}
}
if (!$isNew && $logger) {
$logger(" User {$j} ({$username}) being updated...");
$this->roleManager->associateRoles($userEntity, $additionalRoles);
}
if ($isNew) {
if ($logger) {
$logger(" User {$j} ({$username}) being created...");
}
$this->createUser($userEntity, $sendMail, $additionalRoles, $model, $username . uniqid(), $organizations, $hasPersonalWorkspace, false);
}
$this->objectManager->persist($userEntity);
$returnValues[] = $firstName . ' ' . $lastName;
if ($group) {
$this->groupManager->addUsersToGroup($group, [$userEntity]);
}
if ($logger) {
$logger(' [UOW size: ' . $this->objectManager->getUnitOfWork()->size() . ']');
}
++$i;
++$j;
if ($i % self::MAX_USER_BATCH_SIZE === 0) {
if ($logger) {
$logger(' [UOW size: ' . $this->objectManager->getUnitOfWork()->size() . ']');
}
$this->objectManager->forceFlush();
if ($logger) {
$logger(' flushing users...');
}
$tmpRoles = $additionalRoles;
$this->objectManager->clear();
$additionalRoles = [];
foreach ($tmpRoles as $toAdd) {
if ($toAdd) {
$additionalRoles[] = $this->objectManager->merge($toAdd);
}
}
if ($this->tokenStorage->getToken()) {
$this->objectManager->merge($this->tokenStorage->getToken()->getUser());
}
}
}
$this->objectManager->endFlushSuite();
if ($logger) {
$logger($countCreated . ' users created.');
$logger($countUpdated . ' users updated.');
}
foreach ($skipped as $key => $user) {
$logger('The user ' . $user . ' was skipped at line ' . $key . ' because it failed the validation pass.');
}
return $returnValues;
}