src/Repository/UserRepository.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use App\Entity\User;
  4. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
  9. /**
  10.  * @method User|null find($id, $lockMode = null, $lockVersion = null)
  11.  * @method User|null findOneBy(array $criteria, array $orderBy = null)
  12.  * @method User[]    findAll()
  13.  * @method User[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  14.  */
  15. class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
  16. {
  17.     public function __construct(ManagerRegistry $registry)
  18.     {
  19.         parent::__construct($registryUser::class);
  20.     }
  21.     /**
  22.      * Used to upgrade (rehash) the user's password automatically over time.
  23.      */
  24.     public function upgradePassword(PasswordAuthenticatedUserInterface $userstring $newHashedPassword): void
  25.     {
  26.         if (!$user instanceof User) {
  27.             throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.'\get_class($user)));
  28.         }
  29.         $user->setPassword($newHashedPassword);
  30.         $this->_em->persist($user);
  31.         $this->_em->flush();
  32.     }
  33.     public function findUserFirmenmitglieder($firmenprofilId$sortNach1$sortNach2$sort)
  34.     {
  35.         $queryBuilder $this->createQueryBuilder('u')
  36.             ->innerJoin('u.user_profil''up')
  37.             ->andWhere('u.firmen_profil = :firmenprofil')
  38.             ->addOrderBy('up.' $sortNach1$sort)
  39.             ->addOrderBy('up.' $sortNach2'ASC');
  40.         $queryBuilder->setParameter('firmenprofil'$firmenprofilId);
  41.         return $queryBuilder->getQuery()->getResult();
  42.     }
  43.     public function findUserMitBestimmterROLE(string $role)
  44.     {
  45.         return $this->createQueryBuilder('u')
  46.             ->andWhere('u.roles LIKE :role')
  47.             ->setParameter('role''%"' $role '"%')
  48.             ->getQuery()
  49.             ->getResult();
  50.     }
  51.     public function findUserAusserCelseo()
  52.     {
  53.         return $this->createQueryBuilder('u')
  54.             ->andWhere('u.id > 100')
  55.             ->getQuery()
  56.             ->getResult();
  57.     }
  58.     public function findMoeglicheNeueCelseoMasterAccounts()
  59.     {
  60.         return $this->createQueryBuilder('u')
  61.             ->andWhere('u.id < 100')
  62.             ->andWhere('u.firmen_profil IS NULL')
  63.             ->getQuery()
  64.             ->getResult();
  65.     }
  66.     public function findUserMitFirmenverbindung()
  67.     {
  68.         $queryBuilder $this->createQueryBuilder('u')
  69.             ->andWhere('u.firmen_profil IS NOT NULL');
  70.         return $queryBuilder->getQuery()->getResult();
  71.     }
  72.     public function findAdminsMitNewsletterFreigabe(string $role)
  73.     {
  74.         return $this->createQueryBuilder('u')
  75.             ->innerJoin('u.user_profil''up')
  76.             ->andWhere('u.firmen_profil = 1')
  77.             ->andWhere('u.roles LIKE :role')
  78.             ->setParameter('role''%"' $role '"%')
  79.             ->andWhere('up.newsletter = 1')
  80.             ->getQuery()
  81.             ->getResult();
  82.     }
  83.     public function findUserMitBuchungsrechteMitNewsletterFreigabe(string $role)
  84.     {
  85.         return $this->createQueryBuilder('u')
  86.             ->innerJoin('u.user_profil''up')
  87.             ->andWhere('u.firmen_profil > 2')
  88.             ->andWhere('u.id > 100')
  89.             ->andWhere('u.roles LIKE :role')
  90.             ->setParameter('role''%"' $role '"%')
  91.             ->andWhere('up.newsletter = 1')
  92.             ->getQuery()
  93.             ->getResult();
  94.     }
  95.     public function findUserMitFirmenverbindungOhneProvisorischMitNewsletterFreigabe()
  96.     {
  97.         $queryBuilder $this->createQueryBuilder('u')
  98.             ->innerJoin('u.user_profil''up')
  99.             ->andWhere('u.firmen_profil IS NOT NULL')
  100.             ->andWhere('u.firmen_profil > 2')
  101.             ->andWhere('u.freigeschaltet = 1')
  102.             ->andWhere('u.angelegt_am <> u.letzter_login')
  103.             ->andWhere('u.id > 100')
  104.             ->andWhere('u.provisorischer_mitarbeiter IS NULL')
  105.             ->andWhere('up.newsletter = 1');
  106.         return $queryBuilder->getQuery()->getResult();
  107.     }
  108.     public function findAlleFreigeschalteteUserOhneProvisorischMitNewsletterFreigabe()
  109.     {
  110.         $queryBuilder $this->createQueryBuilder('u')
  111.             ->innerJoin('u.user_profil''up')
  112.             ->andWhere('u.freigeschaltet = 1')
  113.             ->andWhere('u.angelegt_am <> u.letzter_login');
  114.         $orStatements $queryBuilder->expr()->orX(
  115.             $queryBuilder->expr()->isNull('u.firmen_profil'),
  116.             $queryBuilder->expr()->gte('u.firmen_profil'2)
  117.         );
  118.         $queryBuilder->andWhere($orStatements);
  119.         $queryBuilder->andWhere('u.id > 100')
  120.             ->andWhere('u.provisorischer_mitarbeiter IS NULL')
  121.             ->andWhere('up.newsletter = 1');
  122.         return $queryBuilder->getQuery()->getResult();
  123.     }
  124.     public function findUserOnline($datumVergangenheit)
  125.     {
  126.         $queryBuilder $this->createQueryBuilder('u')
  127.             ->andWhere('u.letzter_login > :now')
  128.             ->setParameter('now'$datumVergangenheit);
  129.         return $queryBuilder->getQuery()->getResult();
  130.     }
  131.     public function findFirmenmitgliederOhneProvisorisch($firmaId$sortierung)
  132.     {
  133.         $queryBuilder $this->createQueryBuilder('u')
  134.             ->innerJoin('u.user_profil''up')
  135.             ->andWhere('u.provisorischer_mitarbeiter IS NULL')
  136.             ->andWhere('u.firmen_profil = :firmaId')
  137.             ->setParameter('firmaId'$firmaId)
  138.             ->orderBy('up.' $sortierung'ASC');
  139.         return $queryBuilder->getQuery()->getResult();
  140.     }
  141. }