mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-28 13:06:13 +00:00
FIX [regroupment][datamapper] add condition to check if key exists in forms array
This commit is contained in:
parent
a272dabcaf
commit
896b4cdfe3
@ -17,6 +17,7 @@ use Chill\MainBundle\Repository\RegroupmentRepository;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Symfony\Component\Form\DataMapperInterface;
|
use Symfony\Component\Form\DataMapperInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use function array_key_exists;
|
||||||
use function count;
|
use function count;
|
||||||
|
|
||||||
class ExportPickCenterDataMapper implements DataMapperInterface
|
class ExportPickCenterDataMapper implements DataMapperInterface
|
||||||
@ -29,7 +30,7 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function mapDataToForms($data, $forms)
|
public function mapDataToForms($data, $forms)
|
||||||
{
|
{
|
||||||
@ -72,12 +73,14 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
|||||||
$centers[spl_object_hash($center)] = $center;
|
$centers[spl_object_hash($center)] = $center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('regroupment', $forms)) {
|
||||||
foreach ($forms['regroupment']->getData() as $regroupment) {
|
foreach ($forms['regroupment']->getData() as $regroupment) {
|
||||||
/** @var Regroupment $regroupment */
|
/** @var Regroupment $regroupment */
|
||||||
foreach ($regroupment->getCenters() as $center) {
|
foreach ($regroupment->getCenters() as $center) {
|
||||||
$centers[spl_object_hash($center)] = $center;
|
$centers[spl_object_hash($center)] = $center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = array_values($centers);
|
$data = array_values($centers);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user