You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserSolver.php 1.4KB

3 jaren geleden
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }