<?php
namespace App\Form\System;
use App\Controller\SystemController;
use App\Util\CustomType;
use App\Util\GenericForm;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
class EntityGeneration extends CustomType
{
public const NAME = "entity-generation";
public function buildForm(FormBuilderInterface $builder, array $options)
{
$join = [
"fields" => [
"targetEntity" => [
"required" => false,
"type" => TextType::class,
"translation_domain" => "messages"
],
"columns" => [
"allow_add" => true,
"entry_options" => [
"fields" => [
"localColumnName" => [
"required" => false,
"type" => TextType::class
],
"referencedColumnName" => [
"required" => false,
"type" => TextType::class
]
],
"translation_domain" => "messages"
],
"entry_type" => GenericForm::class,
"type" => CollectionType::class
]
]
];
$fields = ["fields" => [
"name" => [
"label" => false,
"type" => TextType::class
],
"logger" => [
"attr" => ["class" => "align-middle d-inline form-check"],
"label" => false,
"required" => false,
"type" => CheckboxType::class
],
"generate" => [
"attr" => ["class" => "align-middle d-inline form-check"],
"label" => false,
"type" => CheckboxType::class
],
"properties" => [
"allow_add" => true,
"entry_type" => DOAAttribute::class,
"label" => false,
"translation_domain" => "messages",
"type" => CollectionType::class
],
"joins" => [
"allow_add" => true,
"entry_options" => $join,
"entry_type" => GenericForm::class,
"prototype_name" => "__value__",
"type" => CollectionType::class
],
"order" => [
"attr" => ["hidden" => true],
"html5" => true,
"required" => false,
"type" => NumberType::class
]
]];
$options["fields"] = [
"namespace" => [
"attr" => ["class" => "form-select"],
"choice_translation_domain" => false,
"choices" => [
"VaciFácil" => "vaciFacil"
],
"type" => ChoiceType::class
],
"platform" => [
"attr" => ["class" => "form-select"],
"choice_translation_domain" => false,
"choices" => [
"SQL Server" => SystemController::SQLServer
],
"type" => ChoiceType::class
],
"actions" => [
"attr" => ["class" => "flex-grow-1"],
"choices" => [
"choices.generate.classes" => 1,
"choices.generate.repositories" => 2,
"choices.generate.sqlScript" => 3,
],
"multiple" => true,
"type" => ChoiceType::class
],
"alterFile" => [
"attr" => ["class" => "form-check-custom"],
"label_attr" => ["class" => "form-control"],
"type" => CheckboxType::class
],
"invert" => [
"attr" => ["class" => "form-check-custom"],
"label_attr" => ["class" => "form-control"],
"label_format" => "label.unmark.selected.entities",
"type" => CheckboxType::class
],
"test" => [
"attr" => ["class" => "form-check-custom"],
"label_attr" => ["class" => "form-control"],
"label_format" => "label.generate.devEnv",
"type" => CheckboxType::class
],
"entity" => [
"allow_add" => true,
"entry_options" => $fields,
"entry_type" => GenericForm::class,
"label" => false,
"prototype_name" => "__alias__",
"translation_domain" => false,
"type" => CollectionType::class
]
];
foreach (array_keys($options["fields"]) as $field) { $options["fields"][$field]["required"] = false; }
parent::buildForm($builder, $options);
}
}