mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Add docgen:read group on Person + 2 fields in PersonContext admin form
This commit is contained in:
@@ -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', [
|
||||
|
Reference in New Issue
Block a user