mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
FEATURE [datamapper][regroupment] minor fix
This commit is contained in:
parent
068311d071
commit
b5ec0919e7
@ -14,8 +14,10 @@ namespace Chill\MainBundle\Form\DataMapper;
|
|||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Regroupment;
|
use Chill\MainBundle\Entity\Regroupment;
|
||||||
use Chill\MainBundle\Repository\RegroupmentRepository;
|
use Chill\MainBundle\Repository\RegroupmentRepository;
|
||||||
|
use Exception;
|
||||||
use Symfony\Component\Form\DataMapperInterface;
|
use Symfony\Component\Form\DataMapperInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use function count;
|
||||||
|
|
||||||
class ExportPickCenterDataMapper implements DataMapperInterface
|
class ExportPickCenterDataMapper implements DataMapperInterface
|
||||||
{
|
{
|
||||||
@ -24,34 +26,39 @@ class ExportPickCenterDataMapper implements DataMapperInterface
|
|||||||
/**
|
/**
|
||||||
* @param array|Center[] $data
|
* @param array|Center[] $data
|
||||||
* @param $forms
|
* @param $forms
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function mapDataToForms($data, $forms)
|
public function mapDataToForms($data, $forms)
|
||||||
{
|
{
|
||||||
throw new \Exception("not implemented");
|
if (null === $data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var array<string, FormInterface> $form */
|
/** @var array<string, FormInterface> $form */
|
||||||
$form = iterator_to_array($forms);
|
$form = iterator_to_array($forms);
|
||||||
|
|
||||||
$pickedRegroupment = [];
|
$pickedRegroupment = [];
|
||||||
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
|
|
||||||
[$contained, $notContained] = $regroupment->getCenters()->partition(function (Center $center) {
|
|
||||||
|
|
||||||
});
|
foreach ($this->regroupmentRepository->findAll() as $regroupment) {
|
||||||
|
[$contained, $notContained] = $regroupment->getCenters()->partition(static function (Center $center) {
|
||||||
|
});
|
||||||
|
|
||||||
if (0 === count($notContained)) {
|
if (0 === count($notContained)) {
|
||||||
$pickedRegroupment[] = $regroupment;
|
$pickedRegroupment[] = $regroupment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$form['regroupment']->setData($pickedRegroupment);
|
$form['regroupment']->setData($pickedRegroupment);
|
||||||
$form['centers']->setData($data);
|
$form['centers']->setData($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param iterable $forms
|
* @param iterable $forms
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function mapFormsToData($forms, &$data)
|
public function mapFormsToData($forms, &$data)
|
||||||
|
@ -16,27 +16,15 @@ use Chill\MainBundle\Entity\Center;
|
|||||||
use Chill\MainBundle\Entity\Regroupment;
|
use Chill\MainBundle\Entity\Regroupment;
|
||||||
use Chill\MainBundle\Export\ExportManager;
|
use Chill\MainBundle\Export\ExportManager;
|
||||||
use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper;
|
use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper;
|
||||||
use Chill\MainBundle\Form\DataMapper\PickCenterDataMapper;
|
|
||||||
use Chill\MainBundle\Form\DataMapper\RegroupmentDataMapper;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
|
||||||
use Symfony\Component\Form\DataMapperInterface;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
|
||||||
use Symfony\Component\Form\FormView;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use function array_intersect;
|
|
||||||
use function array_key_exists;
|
|
||||||
use function array_merge;
|
|
||||||
use function array_unique;
|
|
||||||
use function count;
|
use function count;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pick centers amongst available centers for the user.
|
* Pick centers amongst available centers for the user.
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Chill\MainBundle\Form\Type\Export;
|
namespace Chill\MainBundle\Form\Type\Export;
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
|
||||||
class PickRegroupmentType extends AbstractType
|
class PickRegroupmentType extends AbstractType
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user