src/Form/System/EntityGeneration.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Form\System;
  3. use App\Controller\SystemController;
  4. use App\Util\CustomType;
  5. use App\Util\GenericForm;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  8. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  9. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\FormBuilderInterface;
  12. class EntityGeneration extends CustomType
  13. {
  14.     public const NAME "entity-generation";
  15.     public function buildForm(FormBuilderInterface $builder, array $options)
  16.     {
  17.         $join = [
  18.             "fields" => [
  19.                 "targetEntity" => [
  20.                     "required" => false,
  21.                     "type" => TextType::class,
  22.                     "translation_domain" => "messages"
  23.                 ],
  24.                 "columns" => [
  25.                     "allow_add" => true,
  26.                     "entry_options" => [
  27.                         "fields" => [
  28.                             "localColumnName" => [
  29.                                 "required" => false,
  30.                                 "type" => TextType::class
  31.                             ],
  32.                             "referencedColumnName" => [
  33.                                 "required" => false,
  34.                                 "type" => TextType::class
  35.                             ]
  36.                         ],
  37.                         "translation_domain" => "messages"
  38.                     ],
  39.                     "entry_type" => GenericForm::class,
  40.                     "type" => CollectionType::class
  41.                 ]
  42.             ]
  43.         ];
  44.         $fields = ["fields" => [
  45.             "name" => [
  46.                 "label" => false,
  47.                 "type" => TextType::class
  48.             ],
  49.             "logger" => [
  50.                 "attr" => ["class" => "align-middle d-inline form-check"],
  51.                 "label" => false,
  52.                 "required" => false,
  53.                 "type" => CheckboxType::class
  54.             ],
  55.             "generate" => [
  56.                 "attr" => ["class" => "align-middle d-inline form-check"],
  57.                 "label" => false,
  58.                 "type" => CheckboxType::class
  59.             ],
  60.             "properties" => [
  61.                 "allow_add" => true,
  62.                 "entry_type" => DOAAttribute::class,
  63.                 "label" => false,
  64.                 "translation_domain" => "messages",
  65.                 "type" => CollectionType::class
  66.             ],
  67.             "joins" => [
  68.                 "allow_add" => true,
  69.                 "entry_options" => $join,
  70.                 "entry_type" => GenericForm::class,
  71.                 "prototype_name" => "__value__",
  72.                 "type" => CollectionType::class
  73.             ],
  74.             "order" => [
  75.                 "attr" => ["hidden" => true],
  76.                 "html5" => true,
  77.                 "required" => false,
  78.                 "type" => NumberType::class
  79.             ]
  80.         ]];
  81.         $options["fields"] = [
  82.             "namespace" => [
  83.                 "attr" => ["class" => "form-select"],
  84.                 "choice_translation_domain" => false,
  85.                 "choices" => [
  86.                     "VaciFácil" => "vaciFacil"
  87.                 ],
  88.                 "type" => ChoiceType::class
  89.             ],
  90.             "platform" => [
  91.                 "attr" => ["class" => "form-select"],
  92.                 "choice_translation_domain" => false,
  93.                 "choices" => [
  94.                     "SQL Server" => SystemController::SQLServer
  95.                 ],
  96.                 "type" => ChoiceType::class
  97.             ],
  98.             "actions" => [
  99.                 "attr" => ["class" => "flex-grow-1"],
  100.                 "choices" => [
  101.                     "choices.generate.classes" => 1,
  102.                     "choices.generate.repositories" => 2,
  103.                     "choices.generate.sqlScript" => 3,
  104.                 ],
  105.                 "multiple" => true,
  106.                 "type" => ChoiceType::class
  107.             ],
  108.             "alterFile" => [
  109.                 "attr" => ["class" => "form-check-custom"],
  110.                 "label_attr" => ["class" => "form-control"],
  111.                 "type" => CheckboxType::class
  112.             ],
  113.             "invert" => [
  114.                 "attr" => ["class" => "form-check-custom"],
  115.                 "label_attr" => ["class" => "form-control"],
  116.                 "label_format" => "label.unmark.selected.entities",
  117.                 "type" => CheckboxType::class
  118.             ],
  119.             "test" => [
  120.                 "attr" => ["class" => "form-check-custom"],
  121.                 "label_attr" => ["class" => "form-control"],
  122.                 "label_format" => "label.generate.devEnv",
  123.                 "type" => CheckboxType::class
  124.             ],
  125.             "entity" => [
  126.                 "allow_add" => true,
  127.                 "entry_options" => $fields,
  128.                 "entry_type" => GenericForm::class,
  129.                 "label" => false,
  130.                 "prototype_name" => "__alias__",
  131.                 "translation_domain" => false,
  132.                 "type" => CollectionType::class
  133.             ]
  134.         ];
  135.         foreach (array_keys($options["fields"]) as $field) { $options["fields"][$field]["required"] = false; }
  136.         parent::buildForm($builder$options);
  137.     }
  138. }