Skip to content

Commit

Permalink
replaces removed _em attr with supported function call equivalent.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Feb 26, 2024
1 parent a8adfad commit fa74208
Show file tree
Hide file tree
Showing 51 changed files with 230 additions and 204 deletions.
2 changes: 1 addition & 1 deletion src/Repository/AamcMethodRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(

protected function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(AamcMethod::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(AamcMethod::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$qb->where($qb->expr()->in('x.id', ':ids'));
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AamcPcrsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(AamcPcrs::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(AamcPcrs::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand Down
6 changes: 5 additions & 1 deletion src/Repository/AamcResourceTypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(AamcResourceType::class, 'x');
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('x')
->distinct()
->from(AamcResourceType::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand Down
6 changes: 5 additions & 1 deletion src/Repository/AlertChangeTypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(AlertChangeType::class, 'x');
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('x')
->distinct()
->from(AlertChangeType::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AlertRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(Alert::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(Alert::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand Down
8 changes: 6 additions & 2 deletions src/Repository/ApplicationConfigRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(ApplicationConfig::class, 'x');
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('x')
->distinct()
->from(ApplicationConfig::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$applicationConfigDTOs = [];
Expand All @@ -53,7 +57,7 @@ protected function getValues(): array
if (! $this->cacheEnabled || ! isset($cache)) {
$cache = [];

$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('x.value, x.name')->from(ApplicationConfig::class, 'x');

$configs = $qb->getQuery()->getArrayResult();
Expand Down
6 changes: 5 additions & 1 deletion src/Repository/AssessmentOptionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(AssessmentOption::class, 'x');
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('x')
->distinct()
->from(AssessmentOption::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/AuditLogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function findDTOsBy(array $criteria, array $orderBy = null, $limit = null
*/
public function findInRange(DateTime $from, DateTime $to): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a as log', 'u.id as userId')
->from('App\Entity\AuditLog', 'a')
->leftJoin('a.user', 'u')
Expand Down Expand Up @@ -69,7 +69,7 @@ public function findInRange(DateTime $from, DateTime $to): array
*/
public function deleteInRange(DateTime $from, DateTime $to)
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb
->delete('App\Entity\AuditLog', 'a')
->add(
Expand Down Expand Up @@ -100,7 +100,7 @@ public function deleteInRange(DateTime $from, DateTime $to)
*/
public function writeLogs(array $entries)
{
$conn = $this->_em->getConnection();
$conn = $this->getEntityManager()->getConnection();
$now = new DateTime();
$timestamp = $now->format('Y-m-d H:i:s');
$logs = array_map(function (array $entry) use ($timestamp) {
Expand Down
10 changes: 7 additions & 3 deletions src/Repository/AuthenticationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
public function findOneByUsername($username): ?AuthenticationInterface
{
$username = strtolower($username);
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a')->from(Authentication::class, 'a');
$qb->where($qb->expr()->eq(
$qb->expr()->lower('a.username'),
Expand Down Expand Up @@ -81,15 +81,19 @@ protected function findIdsBy(array $criteria, array $orderBy = null, $limit = nu
*/
public function getUsernames(): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->addSelect('a.username')->from(Authentication::class, 'a');

return array_map(fn(array $arr) => $arr['username'], $qb->getQuery()->getScalarResult());
}

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(Authentication::class, 'x');
$qb = $this->getEntityManager()
->createQueryBuilder()
->select('x')
->distinct()
->from(Authentication::class, 'x');
$qb->where($qb->expr()->in('x.user', ':ids'));
$qb->setParameter(':ids', $ids);

Expand Down
4 changes: 2 additions & 2 deletions src/Repository/CohortRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(Cohort::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(Cohort::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);

Expand All @@ -42,7 +42,7 @@ public function hydrateDTOsFromIds(array $ids): array
}
$cohortIds = array_keys($dtos);

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select('c.id as cohortId, py.id as programYearId, p.id as programId, s.id as schoolId')
->from(Cohort::class, 'c')
->join('c.programYear', 'py')
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/CompetencyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(Competency::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(Competency::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
$dtos = [];
Expand All @@ -48,7 +48,7 @@ public function hydrateDTOsFromIds(array $ids): array
);
}
$competencyIds = array_keys($dtos);
$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select('x.id as competencyId, s.id as schoolId, p.id as parentId')
->from(Competency::class, 'x')
->join('x.school', 's')
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/CourseClerkshipTypeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select('x')->distinct()
->from(CourseClerkshipType::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
Expand Down
7 changes: 4 additions & 3 deletions src/Repository/CourseLearningMaterialRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')
->distinct()->from(CourseLearningMaterial::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
Expand All @@ -49,7 +49,7 @@ public function hydrateDTOsFromIds(array $ids): array
);
}

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select(
'x.id as xId, learningMaterial.id AS learningMaterialId, ' .
'course.id AS courseId, course.locked AS courseIsLocked, course.archived AS courseIsArchived, ' .
Expand Down Expand Up @@ -109,7 +109,8 @@ protected function attachCriteriaToQueryBuilder(

public function getTotalCourseLearningMaterialCount(): int
{
return (int) $this->_em->createQuery('SELECT COUNT(l.id) FROM App\Entity\CourseLearningMaterial l')
return (int) $this->getEntityManager()
->createQuery('SELECT COUNT(l.id) FROM App\Entity\CourseLearningMaterial l')
->getSingleScalarResult();
}
}
8 changes: 4 additions & 4 deletions src/Repository/CourseObjectiveRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')
->distinct()->from(CourseObjective::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
Expand All @@ -46,7 +46,7 @@ public function hydrateDTOsFromIds(array $ids): array
}
$courseObjectiveIds = array_keys($dtos);

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select(
'x.id AS xId, ' .
'course.id AS courseId, course.locked AS courseIsLocked, course.archived AS courseIsArchived, ' .
Expand All @@ -65,7 +65,7 @@ public function hydrateDTOsFromIds(array $ids): array
$dtos[$arr['xId']]->school = (int) $arr['schoolId'];
}

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select('x.id as id, a.id as ancestorId')
->from(CourseObjective::class, 'x')
->leftJoin('x.ancestor', 'a')
Expand Down Expand Up @@ -127,7 +127,7 @@ protected function attachCriteriaToQueryBuilder(
*/
public function getTotalObjectiveCount(): int
{
return (int) $this->_em->createQuery('SELECT COUNT(o.id) FROM App\Entity\CourseObjective o')
return (int) $this->getEntityManager()->createQuery('SELECT COUNT(o.id) FROM App\Entity\CourseObjective o')
->getSingleScalarResult();
}
}
22 changes: 11 additions & 11 deletions src/Repository/CourseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function findDTOsByQ(
int $limit = null,
int $offset = null,
): array {
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->addSelect('x')->from(Course::class, 'x');

$terms = explode(' ', $q);
Expand Down Expand Up @@ -97,7 +97,7 @@ public function findDTOsByQ(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')->distinct()->from(Course::class, 'x');
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')->distinct()->from(Course::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);

Expand Down Expand Up @@ -143,7 +143,7 @@ public function getYears(): array
*/
public function getIds(): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->addSelect('x.id')->from(Course::class, 'x');

return array_map(fn(array $arr) => $arr['id'], $qb->getQuery()->getScalarResult());
Expand Down Expand Up @@ -196,7 +196,7 @@ protected function findMyCourses(
?int $limit = null,
?int $offset = null
): array {
$meta = $this->_em->getClassMetadata(Course::class);
$meta = $this->getEntityManager()->getClassMetadata(Course::class);

if (empty($orderBy)) {
$orderBy = ['id' => 'ASC'];
Expand Down Expand Up @@ -359,7 +359,7 @@ protected function attachAssociationsToDTOs(array $dtos): array
}
$courseIds = array_keys($dtos);

$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('s.id as schoolId, cl.id as clerkshipTypeId, a.id as ancestorId, c.id as courseId')
->from(Course::class, 'c')
->join('c.school', 's')
Expand Down Expand Up @@ -559,7 +559,7 @@ protected function attachCriteriaToQueryBuilder(
*/
public function getCourseIndexesFor(array $courseIds): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select(
'c.id AS id, c.title AS title, c.level AS level, c.year AS year, ' .
'c.startDate AS startDate, c.endDate AS endDate, c.externalId AS externalId, ' .
Expand Down Expand Up @@ -649,7 +649,7 @@ public function getCourseIndexesFor(array $courseIds): array
}
}

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select("c.id AS courseId, l.id as learningMaterialId, l.relativePath, " .
"l.title, l.description, l.citation")
->from(Course::class, 'c')
Expand Down Expand Up @@ -695,7 +695,7 @@ public function getCourseIndexesFor(array $courseIds): array
*/
protected function joinResults(string $from, string $rel, string $select, array $ids): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select("f.id AS fromId, {$select}")->from($from, 'f')
->join("f.{$rel}", 'r')
->where($qb->expr()->in('f.id', ':ids'))
Expand All @@ -713,7 +713,7 @@ protected function joinResults(string $from, string $rel, string $select, array
*/
protected function joinObjectiveResults(string $from, string $rel, string $select, array $ids): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select("f.id AS fromId, {$select}")->from($from, 'f')
->join("f.{$rel}", 'o')
->where($qb->expr()->in('f.id', ':ids'))
Expand All @@ -729,7 +729,7 @@ protected function joinObjectiveResults(string $from, string $rel, string $selec

protected function sessionDataForIndex(array $sessionIds): array
{
$qb = $this->_em->createQueryBuilder();
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select(
's.id AS sessionId, s.title AS title, s.description AS description, c.id as courseId, ' .
'st.title AS sessionType'
Expand Down Expand Up @@ -797,7 +797,7 @@ protected function sessionDataForIndex(array $sessionIds): array
}
}

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select("s.id AS sessionId, l.id as learningMaterialId, l.relativePath, " .
"l.title, l.description, l.citation")
->from(Session::class, 's')
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/CurriculumInventoryAcademicLevelRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')
->distinct()->from(CurriculumInventoryAcademicLevel::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
Expand All @@ -47,7 +47,7 @@ public function hydrateDTOsFromIds(array $ids): array
}
$curriculumInventoryAcademicLevelIds = array_keys($dtos);

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select(
'x.id as xId, report.id AS reportId, school.id AS schoolId'
)
Expand Down
4 changes: 2 additions & 2 deletions src/Repository/CurriculumInventoryExportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(

public function hydrateDTOsFromIds(array $ids): array
{
$qb = $this->_em->createQueryBuilder()->select('x')
$qb = $this->getEntityManager()->createQueryBuilder()->select('x')
->distinct()->from(CurriculumInventoryExport::class, 'x');
$qb->where($qb->expr()->in('x.id', ':ids'));
$qb->setParameter(':ids', $ids);
Expand All @@ -44,7 +44,7 @@ public function hydrateDTOsFromIds(array $ids): array
);
}

$qb = $this->_em->createQueryBuilder()
$qb = $this->getEntityManager()->createQueryBuilder()
->select(
'x.id as xId, user.id AS userId, report.id as reportId'
)
Expand Down

0 comments on commit fa74208

Please sign in to comment.