WIP [centerHistory] Try to get test to work for personCenterHistory

This commit is contained in:
2023-08-03 11:40:47 +02:00
parent fd79692f6d
commit 3af065e530
3 changed files with 37 additions and 15 deletions

View File

@@ -4,11 +4,11 @@ namespace Chill\PersonBundle\Actions\Remove\Handler;
use Chill\PersonBundle\Actions\Remove\PersonMoveSqlHandlerInterface;
use Chill\PersonBundle\Entity\Person;
use Doctrine\ORM\EntityManagerInterface;
use Chill\PersonBundle\Repository\Person\PersonCenterHistoryRepository;
class PersonMoveCenterHistoryHandler implements PersonMoveSqlHandlerInterface
{
public function __construct(private EntityManagerInterface $em)
public function __construct(private PersonCenterHistoryRepository $centerHistoryRepository)
{
}
@@ -23,15 +23,13 @@ class PersonMoveCenterHistoryHandler implements PersonMoveSqlHandlerInterface
$oldestDateA = null;
$oldestDateB = null;
$centerHistoriesA = $this->em->getRepository(Person\PersonCenterHistory::class)->findBy(['person' => $from->getId()]);
// $centerHistoriesA = $from->getCenterHistory()->toArray();
$centerHistoriesA = $this->centerHistoryRepository->findBy(['person' => $from]);
$datesArrayA = array_map(fn($centerHistory) => $centerHistory->getStartDate(), $centerHistoriesA);
if (!count($datesArrayA) === 0) {
$oldestDateA = min($datesArrayA);
}
$centerHistoriesB = $this->em->getRepository(Person\PersonCenterHistory::class)->findBy(['person' => $to->getId()]);
// $centerHistoriesB = $to->getCenterHistory()->toArray();
$centerHistoriesB = $this->centerHistoryRepository->findBy(['person' => $to]);
$datesArrayB = array_map(fn($centerHistory) => $centerHistory->getStartDate(), $centerHistoriesB);
if (!count($datesArrayB) === 0) {