Skip to content

Commit 7ef0d56

Browse files
committed
FormsExtension: uses configuration Schema
1 parent c30df77 commit 7ef0d56

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"latte/latte": "^2.4.1",
2727
"tracy/tracy": "^2.4"
2828
},
29+
"conflict": {
30+
"nette/di": "<3.0-stable"
31+
},
2932
"autoload": {
3033
"classmap": ["src/"]
3134
},

src/Bridges/FormsDI/FormsExtension.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@
1717
*/
1818
class FormsExtension extends Nette\DI\CompilerExtension
1919
{
20-
private $defaults = [
21-
'messages' => [],
22-
];
20+
public function __construct()
21+
{
22+
$this->config = new class {
23+
/** @var string[] */
24+
public $messages = [];
25+
};
26+
}
2327

2428

2529
public function afterCompile(Nette\PhpGenerator\ClassType $class)
2630
{
2731
$initialize = $class->getMethod('initialize');
28-
$config = $this->validateConfig($this->defaults);
2932

30-
foreach ((array) $config['messages'] as $name => $text) {
33+
foreach ($this->config->messages as $name => $text) {
3134
if (defined('Nette\Forms\Form::' . $name)) {
3235
$initialize->addBody('Nette\Forms\Validator::$messages[Nette\Forms\Form::?] = ?;', [$name, $text]);
3336
} elseif (defined($name)) {

0 commit comments

Comments
 (0)