@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'class' => TextType::class, |
| 32 | 32 | 'default_options' => [ |
| 33 | 33 | 'constraints' => [ |
| 34 | - 'not_blank' => [], |
|
| 34 | + 'not_blank' => [ ], |
|
| 35 | 35 | ], |
| 36 | 36 | ], |
| 37 | 37 | ], |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'class' => TextareaType::class, |
| 40 | 40 | 'default_options' => [ |
| 41 | 41 | 'constraints' => [ |
| 42 | - 'not_blank' => [], |
|
| 42 | + 'not_blank' => [ ], |
|
| 43 | 43 | ], |
| 44 | 44 | ], |
| 45 | 45 | ], |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | 'class' => EmailType::class, |
| 48 | 48 | 'default_options' => [ |
| 49 | 49 | 'constraints' => [ |
| 50 | - 'not_blank' => [], |
|
| 51 | - 'email' => [], |
|
| 50 | + 'not_blank' => [ ], |
|
| 51 | + 'email' => [ ], |
|
| 52 | 52 | ], |
| 53 | 53 | ], |
| 54 | 54 | ], |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'class' => PasswordType::class, |
| 57 | 57 | 'default_options' => [ |
| 58 | 58 | 'constraints' => [ |
| 59 | - 'not_blank' => [], |
|
| 59 | + 'not_blank' => [ ], |
|
| 60 | 60 | ], |
| 61 | 61 | ], |
| 62 | 62 | ], |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | 'class' => UrlType::class, |
| 65 | 65 | 'default_options' => [ |
| 66 | 66 | 'constraints' => [ |
| 67 | - 'not_blank' => [], |
|
| 68 | - 'url' => [], |
|
| 67 | + 'not_blank' => [ ], |
|
| 68 | + 'url' => [ ], |
|
| 69 | 69 | ], |
| 70 | 70 | ], |
| 71 | 71 | ], |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | 'class' => TelType::class, |
| 74 | 74 | 'default_options' => [ |
| 75 | 75 | 'constraints' => [ |
| 76 | - 'not_blank' => [], |
|
| 76 | + 'not_blank' => [ ], |
|
| 77 | 77 | ], |
| 78 | 78 | ], |
| 79 | 79 | ], |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | 'class' => IntegerType::class, |
| 84 | 84 | 'default_options' => [ |
| 85 | 85 | 'constraints' => [ |
| 86 | - 'not_blank' => [], |
|
| 86 | + 'not_blank' => [ ], |
|
| 87 | 87 | 'type' => [ |
| 88 | 88 | 'type' => 'integer', |
| 89 | 89 | ], |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | 'class' => MoneyType::class, |
| 95 | 95 | 'default_options' => [ |
| 96 | 96 | 'constraints' => [ |
| 97 | - 'not_blank' => [], |
|
| 97 | + 'not_blank' => [ ], |
|
| 98 | 98 | 'type' => [ |
| 99 | 99 | 'type' => 'numeric', |
| 100 | 100 | ], |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'class' => NumberType::class, |
| 106 | 106 | 'default_options' => [ |
| 107 | 107 | 'constraints' => [ |
| 108 | - 'not_blank' => [], |
|
| 108 | + 'not_blank' => [ ], |
|
| 109 | 109 | 'type' => [ |
| 110 | 110 | 'type' => 'numeric', |
| 111 | 111 | ], |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | 'class' => PercentType::class, |
| 117 | 117 | 'default_options' => [ |
| 118 | 118 | 'constraints' => [ |
| 119 | - 'not_blank' => [], |
|
| 119 | + 'not_blank' => [ ], |
|
| 120 | 120 | 'type' => [ |
| 121 | 121 | 'type' => 'numeric', |
| 122 | 122 | ], |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | 'class' => ChoiceType::class, |
| 130 | 130 | 'default_options' => [ |
| 131 | 131 | 'constraints' => [ |
| 132 | - 'not_blank' => [], |
|
| 132 | + 'not_blank' => [ ], |
|
| 133 | 133 | ], |
| 134 | 134 | ], |
| 135 | 135 | ], |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'class' => CountryType::class, |
| 138 | 138 | 'default_options' => [ |
| 139 | 139 | 'constraints' => [ |
| 140 | - 'not_blank' => [], |
|
| 140 | + 'not_blank' => [ ], |
|
| 141 | 141 | ], |
| 142 | 142 | ], |
| 143 | 143 | ], |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | 'class' => LanguageType::class, |
| 146 | 146 | 'default_options' => [ |
| 147 | 147 | 'constraints' => [ |
| 148 | - 'not_blank' => [], |
|
| 148 | + 'not_blank' => [ ], |
|
| 149 | 149 | ], |
| 150 | 150 | ], |
| 151 | 151 | ], |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | 'class' => LocaleType::class, |
| 154 | 154 | 'default_options' => [ |
| 155 | 155 | 'constraints' => [ |
| 156 | - 'not_blank' => [], |
|
| 156 | + 'not_blank' => [ ], |
|
| 157 | 157 | ], |
| 158 | 158 | ], |
| 159 | 159 | ], |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'class' => TimezoneType::class, |
| 162 | 162 | 'default_options' => [ |
| 163 | 163 | 'constraints' => [ |
| 164 | - 'not_blank' => [], |
|
| 164 | + 'not_blank' => [ ], |
|
| 165 | 165 | ], |
| 166 | 166 | ], |
| 167 | 167 | ], |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | 'class' => CurrencyType::class, |
| 170 | 170 | 'default_options' => [ |
| 171 | 171 | 'constraints' => [ |
| 172 | - 'not_blank' => [], |
|
| 172 | + 'not_blank' => [ ], |
|
| 173 | 173 | ], |
| 174 | 174 | ], |
| 175 | 175 | ], |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | // 'placeholder' => 'dd/mm/aaaa', |
| 187 | 187 | // ] |
| 188 | 188 | 'constraints' => [ |
| 189 | - 'not_blank' => [], |
|
| 190 | - 'date' => [], |
|
| 189 | + 'not_blank' => [ ], |
|
| 190 | + 'date' => [ ], |
|
| 191 | 191 | ], |
| 192 | 192 | ], |
| 193 | 193 | ], |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | 'widget' => 'single_text', |
| 199 | 199 | 'with_seconds' => false, |
| 200 | 200 | 'constraints' => [ |
| 201 | - 'not_blank' => [], |
|
| 202 | - 'time' => [], |
|
| 201 | + 'not_blank' => [ ], |
|
| 202 | + 'time' => [ ], |
|
| 203 | 203 | ], |
| 204 | 204 | ], |
| 205 | 205 | ], |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | public static function getDefaultTypeConfig(string $inputType): array |
| 223 | 223 | { |
| 224 | - if (!isset(self::SUPPORTED_TYPES[$inputType])) { |
|
| 224 | + if (!isset(self::SUPPORTED_TYPES[ $inputType ])) { |
|
| 225 | 225 | throw new NotSupportedFormTypeException($inputType); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - return self::SUPPORTED_TYPES[$inputType]; |
|
| 228 | + return self::SUPPORTED_TYPES[ $inputType ]; |
|
| 229 | 229 | } |
| 230 | 230 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $this->formFactory = $formFactory; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function createFormFromYaml(string $formConfigYaml, array $formOptions = [], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 26 | + public function createFormFromYaml(string $formConfigYaml, array $formOptions = [ ], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 27 | 27 | { |
| 28 | 28 | $array = Yaml::parse($formConfigYaml); |
| 29 | 29 | $json = json_encode($array); |
@@ -31,14 +31,14 @@ discard block |
||
| 31 | 31 | return $this->createFormFromJson($json, $formOptions, $data, $baseFormTypeClass, $groupName); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function createFormFromJson(string $formConfigJson, array $formOptions = [], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 34 | + public function createFormFromJson(string $formConfigJson, array $formOptions = [ ], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 35 | 35 | { |
| 36 | 36 | $formConfig = json_decode($formConfigJson, true); |
| 37 | 37 | |
| 38 | 38 | return $this->createForm($formConfig, $formOptions, $data, $baseFormTypeClass, $groupName); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function createForm(array $formConfig, array $formOptions = [], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 41 | + public function createForm(array $formConfig, array $formOptions = [ ], $data = null, string $baseFormTypeClass = null, string $groupName = null): ?FormInterface |
|
| 42 | 42 | { |
| 43 | 43 | if (empty($formConfig)) { |
| 44 | 44 | return null; |
@@ -53,34 +53,34 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | foreach ($formConfig as $inputName => $inputConfig) { |
| 56 | - $inputType = isset($inputConfig['type']) ? $inputConfig['type'] : 'text'; |
|
| 56 | + $inputType = isset($inputConfig[ 'type' ]) ? $inputConfig[ 'type' ] : 'text'; |
|
| 57 | 57 | |
| 58 | 58 | // Se obtiene la configuración predeterminada |
| 59 | 59 | if (class_exists($inputType)) { |
| 60 | 60 | $inputDefaultConfig = [ |
| 61 | 61 | 'class' => $inputType, |
| 62 | - 'default_options' => [], |
|
| 62 | + 'default_options' => [ ], |
|
| 63 | 63 | ]; |
| 64 | 64 | } else { |
| 65 | 65 | $inputDefaultConfig = SupportedTypes::getDefaultTypeConfig($inputType); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // se obtienen las opciones definidas para este input |
| 69 | - $inputOptions = isset($inputConfig['options']) ? $inputConfig['options'] : []; |
|
| 69 | + $inputOptions = isset($inputConfig[ 'options' ]) ? $inputConfig[ 'options' ] : [ ]; |
|
| 70 | 70 | |
| 71 | - $inputOptions['constraints'] = $this->getConstraints($inputType, $inputDefaultConfig['default_options'], $inputOptions); |
|
| 71 | + $inputOptions[ 'constraints' ] = $this->getConstraints($inputType, $inputDefaultConfig[ 'default_options' ], $inputOptions); |
|
| 72 | 72 | |
| 73 | 73 | // Se compilan las opciones default con las definidas |
| 74 | 74 | $inputOptions = array_merge( |
| 75 | - $inputDefaultConfig['default_options'], |
|
| 75 | + $inputDefaultConfig[ 'default_options' ], |
|
| 76 | 76 | $inputOptions |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | // Se crea el input de formulario |
| 80 | 80 | if ($groupName) { |
| 81 | - $form->get($groupName)->add($inputName, $inputDefaultConfig['class'], $inputOptions); |
|
| 81 | + $form->get($groupName)->add($inputName, $inputDefaultConfig[ 'class' ], $inputOptions); |
|
| 82 | 82 | } else { |
| 83 | - $form->add($inputName, $inputDefaultConfig['class'], $inputOptions); |
|
| 83 | + $form->add($inputName, $inputDefaultConfig[ 'class' ], $inputOptions); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -89,31 +89,31 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | private function getConstraints(string $inputType, array $inputDefaultOptions, array $inputOptions) |
| 91 | 91 | { |
| 92 | - $ret = []; |
|
| 92 | + $ret = [ ]; |
|
| 93 | 93 | |
| 94 | - $validations = isset($inputDefaultOptions['constraints']) ? $inputDefaultOptions['constraints'] : []; |
|
| 95 | - $validations = array_merge($validations, isset($inputOptions['constraints']) ? $inputOptions['constraints'] : []); |
|
| 94 | + $validations = isset($inputDefaultOptions[ 'constraints' ]) ? $inputDefaultOptions[ 'constraints' ] : [ ]; |
|
| 95 | + $validations = array_merge($validations, isset($inputOptions[ 'constraints' ]) ? $inputOptions[ 'constraints' ] : [ ]); |
|
| 96 | 96 | |
| 97 | 97 | foreach ($validations as $validation => $validationOptions) { |
| 98 | 98 | switch ($validation) { |
| 99 | 99 | case 'not_blank': |
| 100 | - if (isset($inputOptions['required']) && false === $inputOptions['required']) { |
|
| 100 | + if (isset($inputOptions[ 'required' ]) && false === $inputOptions[ 'required' ]) { |
|
| 101 | 101 | // no se setea la validación |
| 102 | 102 | } else { |
| 103 | - $ret[] = new NotBlank($validationOptions); |
|
| 103 | + $ret[ ] = new NotBlank($validationOptions); |
|
| 104 | 104 | } |
| 105 | 105 | break; |
| 106 | 106 | case 'email': |
| 107 | - $ret[] = new Email($validationOptions); |
|
| 107 | + $ret[ ] = new Email($validationOptions); |
|
| 108 | 108 | break; |
| 109 | 109 | case 'url': |
| 110 | - $ret[] = new Url($validationOptions); |
|
| 110 | + $ret[ ] = new Url($validationOptions); |
|
| 111 | 111 | break; |
| 112 | 112 | case 'length': |
| 113 | - $ret[] = new Length($validationOptions); |
|
| 113 | + $ret[ ] = new Length($validationOptions); |
|
| 114 | 114 | break; |
| 115 | 115 | case 'date': |
| 116 | - $ret[] = new Date($validationOptions); |
|
| 116 | + $ret[ ] = new Date($validationOptions); |
|
| 117 | 117 | break; |
| 118 | 118 | } |
| 119 | 119 | } |