您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

54 行
1.4KB

  1. <?php
  2. namespace Lc\SovBundle\Solver\User;
  3. use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
  4. use Lc\SovBundle\Model\User\GroupUserInterface;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. class UserSolver
  7. {
  8. // @TODO : à écrire si besoin (voir __toString de UserModel)
  9. public function getSummary(UserInterface $user)
  10. {
  11. }
  12. public function getName(UserInterface $user): ?string
  13. {
  14. return (string) ucfirst(strtolower($user->getFirstname())) . ' ' . strtoupper($user->getLastname());
  15. }
  16. // isUserInGroupVip
  17. public function isInGroupUserVip(UserInterface $user)
  18. {
  19. return $this->isInGroupByDevAlias($user, 'vip') ;
  20. }
  21. // isUserInGroup
  22. public function isInGroupUser(UserInterface $user, GroupUserInterface $groupUser)
  23. {
  24. return $this->isInGroupByDevAlias($user, $groupUser->getDevAlias());
  25. }
  26. // isUserInGroupByDevAlias
  27. public function isInGroupByDevAlias(UserInterface $user, string $groupUserDevAlias)
  28. {
  29. $groupUsers = $user->getGroupUsers();
  30. foreach($groupUsers as $groupUser) {
  31. if($groupUser->getDevAlias() == $groupUserDevAlias) {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. public function isSubscribedToNewsletter(UserInterface $user, NewsletterInterface $newsletter)
  38. {
  39. return $user->getNewsletters()->contains($newsletter);
  40. }
  41. }