support multiple teamleads in each team (#2702)
* fix jumping avatars * fix line-break after color dot for long names
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
namespace App\Repository\Loader;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Team;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -18,14 +20,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class ActivityIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,7 @@ final class ActivityIdLoader implements LoaderInterface
|
||||
$em = $this->entityManager;
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
/** @var Activity[] $activities */
|
||||
$activities = $qb->select('PARTIAL a.{id}', 'project')
|
||||
->from(Activity::class, 'a')
|
||||
->leftJoin('a.project', 'project')
|
||||
@@ -58,51 +60,76 @@ final class ActivityIdLoader implements LoaderInterface
|
||||
|
||||
// global activities don't have projects
|
||||
if (!empty($activities)) {
|
||||
$projectIds = array_map(function (Activity $activity) {
|
||||
$projectIds = array_unique(array_map(function (Activity $activity) {
|
||||
if (null === $activity->getProject()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $activity->getProject()->getId();
|
||||
}, $activities);
|
||||
}, $activities));
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL p.{id}', 'customer')
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.customer', 'customer')
|
||||
->andWhere($qb->expr()->in('p.id', $projectIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL a.{id}', 'PARTIAL project.{id}', 'teams', 'teamlead')
|
||||
->from(Activity::class, 'a')
|
||||
->leftJoin('a.project', 'project')
|
||||
->leftJoin('project.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('a.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL a.{id}', 'PARTIAL project.{id}', 'PARTIAL customer.{id}', 'teams', 'teamlead')
|
||||
->from(Activity::class, 'a')
|
||||
->leftJoin('a.project', 'project')
|
||||
$qb->select('PARTIAL project.{id}', 'customer')
|
||||
->from(Project::class, 'project')
|
||||
->leftJoin('project.customer', 'customer')
|
||||
->andWhere($qb->expr()->in('project.id', $projectIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$customerIds = array_unique(array_map(function (Activity $activity) {
|
||||
if (null === $activity->getProject()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $activity->getProject()->getCustomer()->getId();
|
||||
}, $activities));
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL project.{id}', 'teams')
|
||||
->from(Project::class, 'project')
|
||||
->leftJoin('project.teams', 'teams')
|
||||
->andWhere($qb->expr()->in('project.id', $projectIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL customer.{id}', 'teams')
|
||||
->from(Customer::class, 'customer')
|
||||
->leftJoin('customer.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('a.id', $ids))
|
||||
->andWhere($qb->expr()->in('customer.id', $customerIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL a.{id}', 'teams', 'teamlead')
|
||||
$qb->select('PARTIAL a.{id}', 'teams')
|
||||
->from(Activity::class, 'a')
|
||||
->leftJoin('a.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('a.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
// do not load team members or leads by default, because they will only be used on detail pages
|
||||
// and there is no benefit in adding multiple queries for most requests when they are only needed in one place
|
||||
if ($this->fullyHydrated) {
|
||||
$teamIds = [];
|
||||
foreach ($activities as $activity) {
|
||||
foreach ($activity->getTeams() as $team) {
|
||||
$teamIds[] = $team->getId();
|
||||
}
|
||||
}
|
||||
$teamIds = array_unique($teamIds);
|
||||
|
||||
if (\count($teamIds) > 0) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL team.{id}', 'members', 'user')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.members', 'members')
|
||||
->leftJoin('members.user', 'user')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
final class ActivityLoader implements LoaderInterface
|
||||
{
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ final class ActivityLoader implements LoaderInterface
|
||||
return $activity->getId();
|
||||
}, $activities);
|
||||
|
||||
$loader = new ActivityIdLoader($this->entityManager);
|
||||
$loader = new ActivityIdLoader($this->entityManager, $this->fullyHydrated);
|
||||
$loader->loadResults($ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace App\Repository\Loader;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Team;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -17,14 +18,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class CustomerIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,8 @@ final class CustomerIdLoader implements LoaderInterface
|
||||
$em = $this->entityManager;
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL c.{id}', 'meta')
|
||||
/** @var Customer[] $customers */
|
||||
$customers = $qb->select('PARTIAL c.{id}', 'meta')
|
||||
->from(Customer::class, 'c')
|
||||
->leftJoin('c.meta', 'meta')
|
||||
->andWhere($qb->expr()->in('c.id', $ids))
|
||||
@@ -47,12 +48,34 @@ final class CustomerIdLoader implements LoaderInterface
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL c.{id}', 'teams', 'teamlead')
|
||||
$qb->select('PARTIAL c.{id}', 'teams')
|
||||
->from(Customer::class, 'c')
|
||||
->leftJoin('c.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('c.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
// do not load team members or leads by default, because they will only be used on detail pages
|
||||
// and there is no benefit in adding multiple queries for most requests when they are only needed in one place
|
||||
if ($this->fullyHydrated) {
|
||||
$teamIds = [];
|
||||
foreach ($customers as $customer) {
|
||||
foreach ($customer->getTeams() as $team) {
|
||||
$teamIds[] = $team->getId();
|
||||
}
|
||||
}
|
||||
$teamIds = array_unique($teamIds);
|
||||
|
||||
if (\count($teamIds) > 0) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL team.{id}', 'members', 'user')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.members', 'members')
|
||||
->leftJoin('members.user', 'user')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
final class CustomerLoader implements LoaderInterface
|
||||
{
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ final class CustomerLoader implements LoaderInterface
|
||||
return $customer->getId();
|
||||
}, $customers);
|
||||
|
||||
$loader = new CustomerIdLoader($this->entityManager);
|
||||
$loader = new CustomerIdLoader($this->entityManager, $this->fullyHydrated);
|
||||
$loader->loadResults($ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
namespace App\Repository\Loader;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Team;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@@ -17,14 +19,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class ProjectIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,38 +40,63 @@ final class ProjectIdLoader implements LoaderInterface
|
||||
$em = $this->entityManager;
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL p.{id}', 'customer')
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.customer', 'customer')
|
||||
->andWhere($qb->expr()->in('p.id', $ids))
|
||||
/** @var Project[] $projects */
|
||||
$projects = $qb->select('PARTIAL project.{id}', 'customer')
|
||||
->from(Project::class, 'project')
|
||||
->leftJoin('project.customer', 'customer')
|
||||
->andWhere($qb->expr()->in('project.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL p.{id}', 'meta')
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.meta', 'meta')
|
||||
->andWhere($qb->expr()->in('p.id', $ids))
|
||||
$qb->select('PARTIAL project.{id}', 'meta')
|
||||
->from(Project::class, 'project')
|
||||
->leftJoin('project.meta', 'meta')
|
||||
->andWhere($qb->expr()->in('project.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL p.{id}', 'teams', 'teamlead')
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('p.id', $ids))
|
||||
$qb->select('PARTIAL project.{id}', 'teams')
|
||||
->from(Project::class, 'project')
|
||||
->leftJoin('project.teams', 'teams')
|
||||
->andWhere($qb->expr()->in('project.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$customerIds = array_unique(array_map(function (Project $project) {
|
||||
return $project->getCustomer()->getId();
|
||||
}, $projects));
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL p.{id}', 'PARTIAL customer.{id}', 'teams', 'teamlead')
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.customer', 'customer')
|
||||
$qb->select('PARTIAL customer.{id}', 'teams')
|
||||
->from(Customer::class, 'customer')
|
||||
->leftJoin('customer.teams', 'teams')
|
||||
->leftJoin('teams.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('p.id', $ids))
|
||||
->andWhere($qb->expr()->in('customer.id', $customerIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
// do not load team members or leads by default, because they will only be used on detail pages
|
||||
// and there is no benefit in adding multiple queries for most requests when they are only needed in one place
|
||||
if ($this->fullyHydrated) {
|
||||
$teamIds = [];
|
||||
foreach ($projects as $project) {
|
||||
foreach ($project->getTeams() as $team) {
|
||||
$teamIds[] = $team->getId();
|
||||
}
|
||||
}
|
||||
$teamIds = array_unique($teamIds);
|
||||
|
||||
if (\count($teamIds) > 0) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL team.{id}', 'members', 'user')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.members', 'members')
|
||||
->leftJoin('members.user', 'user')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
final class ProjectLoader implements LoaderInterface
|
||||
{
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ final class ProjectLoader implements LoaderInterface
|
||||
return $project->getId();
|
||||
}, $projects);
|
||||
|
||||
$loader = new ProjectIdLoader($this->entityManager);
|
||||
$loader = new ProjectIdLoader($this->entityManager, $this->fullyHydrated);
|
||||
$loader->loadResults($ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class TeamIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
@@ -28,29 +25,30 @@ final class TeamIdLoader implements LoaderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $ids
|
||||
* @param int[] $teamIds
|
||||
*/
|
||||
public function loadResults(array $ids): void
|
||||
public function loadResults(array $teamIds): void
|
||||
{
|
||||
if (empty($ids)) {
|
||||
if (empty($teamIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$em = $this->entityManager;
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL t.{id}', 'users')
|
||||
->from(Team::class, 't')
|
||||
->leftJoin('t.users', 'users')
|
||||
->andWhere($qb->expr()->in('t.id', $ids))
|
||||
$qb->select('PARTIAL team.{id}', 'members', 'user')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.members', 'members')
|
||||
->leftJoin('members.user', 'user')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL t.{id}', 'projects')
|
||||
->from(Team::class, 't')
|
||||
->leftJoin('t.projects', 'projects')
|
||||
->andWhere($qb->expr()->in('t.id', $ids))
|
||||
$qb->select('PARTIAL team.{id}', 'projects')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.projects', 'projects')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
@@ -20,19 +20,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class TimesheetIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $fullyHydrated = false;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $hydrateFullTree = false)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $hydrateFullTree;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,12 +15,12 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
final class TimesheetLoader implements LoaderInterface
|
||||
{
|
||||
private $entityManager;
|
||||
private $hydrateFullTree;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $hydrateFullTree = false)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->hydrateFullTree = $hydrateFullTree;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ final class TimesheetLoader implements LoaderInterface
|
||||
return $timesheet->getId();
|
||||
}, $timesheets);
|
||||
|
||||
$loader = new TimesheetIdLoader($this->entityManager, $this->hydrateFullTree);
|
||||
$loader = new TimesheetIdLoader($this->entityManager, $this->fullyHydrated);
|
||||
$loader->loadResults($ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,13 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*/
|
||||
final class UserIdLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,44 +40,44 @@ final class UserIdLoader implements LoaderInterface
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
/** @var User[] $users */
|
||||
$users = $qb->select('PARTIAL u.{id}', 'teams')
|
||||
->from(User::class, 'u')
|
||||
->leftJoin('u.teams', 'teams')
|
||||
->andWhere($qb->expr()->in('u.id', $ids))
|
||||
$users = $qb->select('PARTIAL user.{id}', 'memberships', 'team')
|
||||
->from(User::class, 'user')
|
||||
->leftJoin('user.memberships', 'memberships')
|
||||
->leftJoin('memberships.team', 'team')
|
||||
->andWhere($qb->expr()->in('user.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL u.{id}', 'preferences')
|
||||
->from(User::class, 'u')
|
||||
->leftJoin('u.preferences', 'preferences')
|
||||
->andWhere($qb->expr()->in('u.id', $ids))
|
||||
$qb->select('PARTIAL user.{id}', 'preferences')
|
||||
->from(User::class, 'user')
|
||||
->leftJoin('user.preferences', 'preferences')
|
||||
->andWhere($qb->expr()->in('user.id', $ids))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$teamIds = [];
|
||||
foreach ($users as $user) {
|
||||
foreach ($user->getTeams() as $team) {
|
||||
$teamIds[] = $team->getId();
|
||||
// do not load team members or leads by default, because they will only be used on detail pages
|
||||
// and there is no benefit in adding multiple queries for most requests when they are only needed in one place
|
||||
if ($this->fullyHydrated) {
|
||||
$teamIds = [];
|
||||
foreach ($users as $user) {
|
||||
foreach ($user->getTeams() as $team) {
|
||||
$teamIds[] = $team->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
$teamIds = array_unique($teamIds);
|
||||
|
||||
if (\count($teamIds) > 0) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL t.{id}', 'teamlead')
|
||||
->from(Team::class, 't')
|
||||
->leftJoin('t.teamlead', 'teamlead')
|
||||
->andWhere($qb->expr()->in('t.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb->select('PARTIAL t.{id}', 'users')
|
||||
->from(Team::class, 't')
|
||||
->leftJoin('t.users', 'users')
|
||||
->andWhere($qb->expr()->in('t.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
if (\count($teamIds) > 0) {
|
||||
$qb = $em->createQueryBuilder();
|
||||
/** @var Team[] $teams */
|
||||
$teams = $qb->select('PARTIAL team.{id}', 'members', 'user')
|
||||
->from(Team::class, 'team')
|
||||
->leftJoin('team.members', 'members')
|
||||
->leftJoin('members.user', 'user')
|
||||
->andWhere($qb->expr()->in('team.id', $teamIds))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
final class UserLoader implements LoaderInterface
|
||||
{
|
||||
private $entityManager;
|
||||
private $fullyHydrated;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, bool $fullyHydrated = false)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fullyHydrated = $fullyHydrated;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ final class UserLoader implements LoaderInterface
|
||||
return $user->getId();
|
||||
}, $users);
|
||||
|
||||
$loader = new UserIdLoader($this->entityManager);
|
||||
$loader = new UserIdLoader($this->entityManager, $this->fullyHydrated);
|
||||
$loader->loadResults($ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user