create contextmanager and refactor docgeneratorTemplateType

This commit is contained in:
2021-11-30 18:35:05 +01:00
parent 0710d6572b
commit 3404d3669c
8 changed files with 132 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ declare(strict_types=1);
namespace Chill\DocGeneratorBundle\Form;
use Chill\DocGeneratorBundle\Context\ContextManager;
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
use Symfony\Component\Form\AbstractType;
@@ -19,17 +21,31 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\DocStoreBundle\Form\StoredObjectType;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
class DocGeneratorTemplateType extends AbstractType
{
private ContextManager $contextManager;
public function __construct(ContextManager $contextManager)
{
$this->contextManager = $contextManager;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$contexts = \array_flip(\array_map(function (DocGeneratorContextInterface $c) {
return $c->getName();
}, $this->contextManager->getContext()));
$builder
->add('name', TranslatableStringFormType::class, [
'label' => 'Nom',
])
->add('context')
->add('context', ChoiceType::class, [
'required' => true,
'label' => 'Context',
'choices' => $contexts
])
->add('entities', ChoiceType::class, [
'multiple' => true,
'choices' => [