[export form] decouple data from PickCenter form

This commit is contained in:
2023-06-01 14:02:48 +02:00
parent 77f8cf0e1a
commit d1e1b1c4ce
5 changed files with 68 additions and 24 deletions

View File

@@ -22,7 +22,10 @@ use function count;
class ExportPickCenterDataMapper implements DataMapperInterface
{
protected RegroupmentRepository $regroupmentRepository;
public function __construct(
private RegroupmentRepository $regroupmentRepository,
) {
}
public function mapDataToForms($data, $forms): void
{
@@ -37,15 +40,15 @@ class ExportPickCenterDataMapper implements DataMapperInterface
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
/** @phpstan-ignore-next-line */
[$contained, $notContained] = $regroupment->getCenters()->partition(static fn (Center $center): bool => false);
[$contained, $notContained] = $regroupment->getCenters()->partition(static fn (int $id, Center $center): bool => false);
if (0 === count($notContained)) {
$pickedRegroupment[] = $regroupment;
}
}
$form['regroupment']->setData($pickedRegroupment);
$form['centers']->setData($data);
$form['regroupment']->setData([]);
$form['center']->setData($data);
}
public function mapFormsToData($forms, &$data): void