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 901B

3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Lc\CaracoleBundle\Solver\User;
  3. use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
  4. use Lc\SovBundle\Model\User\UserInterface;
  5. use Lc\SovBundle\Solver\User\UserSolver as SovUserSolver;
  6. class UserSolver extends SovUserSolver
  7. {
  8. // isUserLinkedToPointSale
  9. public function isLinkedToPointSale(UserInterface $user, PointSaleInterface $pointSale): bool
  10. {
  11. foreach ($user->getUserPointSales() as $userPointSale) {
  12. if ($userPointSale->getPointSale()->getId() == $pointSale->getId()) {
  13. return true;
  14. }
  15. }
  16. return false;
  17. }
  18. public function getAge(UserInterface $user): ?int
  19. {
  20. if ($user->getBirthdate()) {
  21. $now = new \DateTime();
  22. $interval = $now->diff($user->getBirthdate());
  23. return $interval->y;
  24. } else {
  25. return null;
  26. }
  27. }
  28. }