mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 08:03:49 +00:00
[export form] decouple data from PickCenter form
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user