mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add docgen:read group on Person + 2 fields in PersonContext admin form
This commit is contained in:
parent
d163783ed3
commit
7aefa5014c
@ -38,6 +38,7 @@ use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use function count;
|
||||
@ -152,6 +153,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @Birthdate
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $birthdate;
|
||||
|
||||
@ -200,6 +202,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* sf4 check: option inversedBy="birthsIn" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $countryOfBirth;
|
||||
|
||||
@ -237,6 +240,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @Assert\Date
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="birthdate")
|
||||
* @Assert\LessThanOrEqual("today")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $deathdate = null;
|
||||
|
||||
@ -249,6 +253,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @Assert\Email(
|
||||
* checkMX=true
|
||||
* )
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $email = '';
|
||||
|
||||
@ -262,6 +267,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @Assert\Length(
|
||||
* max=255,
|
||||
* )
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $firstName;
|
||||
|
||||
@ -282,6 +288,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @ORM\Column(type="string", length=9, nullable=true)
|
||||
* @Assert\NotNull(message="The gender must be set")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $gender;
|
||||
|
||||
@ -339,6 +346,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $maritalStatus;
|
||||
|
||||
@ -346,6 +354,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* Comment on marital status.
|
||||
*
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private CommentEmbeddable $maritalStatusComment;
|
||||
|
||||
@ -356,6 +365,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
* @Assert\Date
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private ?DateTime $maritalStatusDate = null;
|
||||
|
||||
@ -378,6 +388,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @PhonenumberConstraint(
|
||||
* type="mobile",
|
||||
* )
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private string $mobilenumber = '';
|
||||
|
||||
@ -391,6 +402,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* sf4 check: option inversedBy="nationals" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $nationality;
|
||||
|
||||
@ -400,6 +412,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private ?int $numberOfChildren = null;
|
||||
|
||||
@ -436,6 +449,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @PhonenumberConstraint(
|
||||
* type="landline",
|
||||
* )
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private string $phonenumber = '';
|
||||
|
||||
@ -445,6 +459,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="place_of_birth")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private $placeOfBirth = '';
|
||||
|
||||
|
@ -24,8 +24,11 @@ use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
@ -41,11 +44,14 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
DocumentCategoryRepository $documentCategoryRepository,
|
||||
NormalizerInterface $normalizer,
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
EntityManagerInterface $em,
|
||||
TranslatorInterface $translator,
|
||||
BaseContextData $baseContextData
|
||||
) {
|
||||
$this->documentCategoryRepository = $documentCategoryRepository;
|
||||
@ -53,6 +59,7 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->em = $em;
|
||||
$this->baseContextData = $baseContextData;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function adminFormReverseTransform(array $data): array
|
||||
@ -69,14 +76,10 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
|
||||
|
||||
public function adminFormTransform(array $data): array
|
||||
{
|
||||
// $r = [
|
||||
// 'mainPerson' => $data['mainPerson'] ?? false,
|
||||
// 'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'),
|
||||
// 'person1' => $data['person1'] ?? false,
|
||||
// 'person1Label' => $data['person1Label'] ?? $this->translator->trans('docgen.person 1'),
|
||||
// 'person2' => $data['person2'] ?? false,
|
||||
// 'person2Label' => $data['person2Label'] ?? $this->translator->trans('docgen.person 2'),
|
||||
// ];
|
||||
$r = [
|
||||
'mainPerson' => $data['mainPerson'] ?? false,
|
||||
'mainPersonLabel' => $data['mainPersonLabel'] ?? $this->translator->trans('docgen.Main person'),
|
||||
];
|
||||
|
||||
if (array_key_exists('category', $data)) {
|
||||
$r['category'] = array_key_exists('category', $data) ?
|
||||
@ -89,14 +92,14 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
|
||||
public function buildAdminForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
// ->add('mainPerson', CheckboxType::class, [
|
||||
// 'required' => false,
|
||||
// 'label' => 'docgen.Ask for main person',
|
||||
// ])
|
||||
// ->add('mainPersonLabel', TextType::class, [
|
||||
// 'label' => 'main person label',
|
||||
// 'required' => true,
|
||||
// ])
|
||||
->add('mainPerson', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'docgen.Ask for main person',
|
||||
])
|
||||
->add('mainPersonLabel', TextType::class, [
|
||||
'label' => 'main person label',
|
||||
'required' => true,
|
||||
])
|
||||
// ->add('person1', CheckboxType::class, [
|
||||
// 'required' => false,
|
||||
// 'label' => 'docgen.Ask for person 1',
|
||||
@ -140,7 +143,6 @@ class PersonContext implements DocGeneratorContextWithAdminFormInterface
|
||||
'docgen:expects' => Person::class,
|
||||
'groups' => 'docgen:read'
|
||||
]);
|
||||
|
||||
// foreach (['mainPerson', 'person1', 'person2'] as $k) {
|
||||
// if ($options[$k]) {
|
||||
// $data[$k] = $this->normalizer->normalize($contextGenerationData[$k], 'docgen', [
|
||||
|
@ -541,6 +541,8 @@ docgen:
|
||||
A basic context for accompanying period: Contexte pour les parcours
|
||||
A context for accompanying period work: Contexte pour les actions d'accompagnement
|
||||
A context for accompanying period work evaluation: Contexte pour les évaluations dans les actions d'accompagnement
|
||||
Person basic: Personne (basique)
|
||||
A basic context for person: Contexte pour les personnes
|
||||
|
||||
period_notification:
|
||||
period_designated_subject: Vous êtes référent d'un parcours d'accompagnement
|
||||
|
Loading…
x
Reference in New Issue
Block a user