Skip to content

Commit

Permalink
update preset repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
KaydenLiss committed Aug 10, 2023
1 parent c26d531 commit e7435f5
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 439 deletions.
4 changes: 2 additions & 2 deletions src/Controller/AuditTomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function addAuditTom(
$audit->setUser($this->getUser());
$status = $auditTomStatusRepository->findAll();
$ziele = $auditTomZieleRepository->findByTeam($team);
$abteilungen = $auditTomAbteilungRepository->findAllByTeam($team);
$abteilungen = $auditTomAbteilungRepository->findActiveByTeam($team);

$form = $this->createForm(
AuditTomType::class,
Expand Down Expand Up @@ -156,7 +156,7 @@ public function editAuditTom(

$today = new DateTime();
$status = $auditTomStatusRepository->findAll();
$abteilungen = $auditTomAbteilungRepository->findAllByTeam($team);
$abteilungen = $auditTomAbteilungRepository->findActiveByTeam($team);
$ziele = $auditTomZieleRepository->findByTeam($team);


Expand Down
2 changes: 1 addition & 1 deletion src/Controller/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function abteilungenAdd(
return $this->redirectToRoute('dashboard');
}

$departments = $departmentRepository->findAllByTeam($team);
$departments = $departmentRepository->findActiveByTeam($team);

if ($request->get('id')) {
$department = $departmentRepository->find($request->get('id'));
Expand Down
48 changes: 7 additions & 41 deletions src/Repository/AuditTomAbteilungRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Repository;

use App\Entity\AuditTomAbteilung;
use App\Entity\Team;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

Expand All @@ -14,53 +15,18 @@
*/
class AuditTomAbteilungRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
public function __construct(
ManagerRegistry $registry,
private readonly TeamRepository $teamRepository,
)
{
parent::__construct($registry, AuditTomAbteilung::class);
}

// /**
// * @return AuditTomAbteilung[] Returns an array of AuditTomAbteilung objects
// */
/*
public function findByExampleField($value)
public function findActiveByTeam(Team $team)
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->orderBy('a.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?AuditTomAbteilung
{
return $this->createQueryBuilder('a')
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
$teamPath = $this->teamRepository->getPath($team);

public function findAllByTeam($value)
{
return $this->createQueryBuilder('a')
->Where('a.team = :val')
->andWhere('a.activ = 1')
->setParameter('val', $value)
->getQuery()
->getResult()
;
}

public function findActiveByTeamPath(array $teamPath)
{
return $this->createQueryBuilder('a')
->where('a.team IN (:teamPath)')
->andWhere('a.activ = 1')
Expand Down
46 changes: 6 additions & 40 deletions src/Repository/DatenweitergabeGrundlagenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,18 @@
*/
class DatenweitergabeGrundlagenRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
public function __construct(
ManagerRegistry $registry,
private readonly TeamRepository $teamRepository,
)
{
parent::__construct($registry, DatenweitergabeGrundlagen::class);
}

// /**
// * @return DatenweitergabeGrundlagen[] Returns an array of DatenweitergabeGrundlagen objects
// */
/*
public function findByExampleField($value)
public function findActiveByTeam($team)
{
return $this->createQueryBuilder('d')
->andWhere('d.exampleField = :val')
->setParameter('val', $value)
->orderBy('d.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?DatenweitergabeGrundlagen
{
return $this->createQueryBuilder('d')
->andWhere('d.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/

public function findActiveByTeam($value)
{
return $this->createQueryBuilder('a')
->where('a.team is null OR a.team = :val')
->andWhere('a.activ = 1')
->setParameter('val', $value)
->getQuery()
->getResult();
}
$teamPath = $this->teamRepository->getPath($team);

public function findActiveByTeamPath(array $teamPath)
{
return $this->createQueryBuilder('a')
->where('a.team is null OR a.team IN (:teamPath)')
->andWhere('a.activ = 1')
Expand Down
47 changes: 7 additions & 40 deletions src/Repository/DatenweitergabeStandRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Repository;

use App\Entity\DatenweitergabeStand;
use App\Entity\Team;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

Expand All @@ -14,52 +15,18 @@
*/
class DatenweitergabeStandRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
public function __construct(
ManagerRegistry $registry,
private readonly TeamRepository $teamRepository,
)
{
parent::__construct($registry, DatenweitergabeStand::class);
}

// /**
// * @return DatenweitergabeStand[] Returns an array of DatenweitergabeStand objects
// */
/*
public function findByExampleField($value)
public function findActiveByTeam(Team $team)
{
return $this->createQueryBuilder('d')
->andWhere('d.exampleField = :val')
->setParameter('val', $value)
->orderBy('d.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?DatenweitergabeStand
{
return $this->createQueryBuilder('d')
->andWhere('d.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/

public function findActiveByTeam($value)
{
return $this->createQueryBuilder('a')
->where('a.team is null OR a.team = :val')
->andWhere('a.activ = 1')
->setParameter('val', $value)
->getQuery()
->getResult();
}
$teamPath = $this->teamRepository->getPath($team);

public function findActiveByTeamPath(array $teamPath)
{
return $this->createQueryBuilder('a')
->where('a.team is null OR a.team IN (:teamPath)')
->andWhere('a.activ = 1')
Expand Down
48 changes: 7 additions & 41 deletions src/Repository/ProdukteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Repository;

use App\Entity\Produkte;
use App\Entity\Team;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

Expand All @@ -14,53 +15,18 @@
*/
class ProdukteRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
public function __construct(
ManagerRegistry $registry,
private readonly TeamRepository $teamRepository,
)
{
parent::__construct($registry, Produkte::class);
}

// /**
// * @return Produkte[] Returns an array of Produkte objects
// */
/*
public function findByExampleField($value)
public function findActiveByTeam(Team $team)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Produkte
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/

public function findActiveByTeam($value)
{
return $this->createQueryBuilder('a')
->andWhere('a.team = :val')
->andWhere('a.activ = 1')
->setParameter('val', $value)
->getQuery()
->getResult()
;
}
$teamPath = $this->teamRepository->getPath($team);

public function findActiveByTeamPath(array $teamPath)
{
return $this->createQueryBuilder('a')
->andWhere('a.team IN (:teamPath)')
->andWhere('a.activ = 1')
Expand Down
49 changes: 7 additions & 42 deletions src/Repository/VVTDatenkategorieRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace App\Repository;

use App\Entity\Team;
use App\Entity\VVTDatenkategorie;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
Expand All @@ -21,7 +22,10 @@
*/
class VVTDatenkategorieRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
public function __construct(
ManagerRegistry $registry,
private readonly TeamRepository $teamRepository,
)
{
parent::__construct($registry, VVTDatenkategorie::class);
}
Expand All @@ -38,49 +42,10 @@ public function add(VVTDatenkategorie $entity, bool $flush = true): void
}
}

// /**
// * @return VVTDatenkategorie[] Returns an array of VVTDatenkategorie objects
// */
/*
public function findByExampleField($value)
public function findByTeam(Team $team)
{
return $this->createQueryBuilder('v')
->andWhere('v.exampleField = :val')
->setParameter('val', $value)
->orderBy('v.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?VVTDatenkategorie
{
return $this->createQueryBuilder('v')
->andWhere('v.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/

public function findByTeam($value)
{
$qb = $this->createQueryBuilder('a');
return $qb
->andWhere('a.team is null OR a.team = :val')
->andWhere($qb->expr()->isNull('a.cloneOf'))
->andWhere('a.activ = 1')
->setParameter('val', $value)
->getQuery()
->getResult();
}
$teamPath = $this->teamRepository->getPath($team);

public function findByTeamPath(array $teamPath)
{
$qb = $this->createQueryBuilder('a');
return $qb
->andWhere('a.team is null OR a.team IN (:teamPath)')
Expand Down
Loading

0 comments on commit e7435f5

Please sign in to comment.