Skip to content

Commit ff8ba86

Browse files
committed
Use Doctrine\DBAL\Types for SQL type definitions in DCA configuration.
1 parent fdc74d8 commit ff8ba86

5 files changed

Lines changed: 40 additions & 18 deletions

File tree

src/Resources/contao/dca/tl_content.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use Doctrine\DBAL\Types\Types;
6+
57
$GLOBALS['TL_DCA']['tl_content']['config']['onload_callback'][] = [
68
'netzmacht.contao_form_designer.listener.dca.content',
79
'initialize',
@@ -17,5 +19,5 @@
1719
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.content', 'getFormLayoutOptions'],
1820
'foreignKey' => 'tl_form_layout.title',
1921
'relation' => ['type' => 'belongsTo', 'load' => 'lazy'],
20-
'sql' => "int(10) unsigned NOT NULL default '0'",
22+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
2123
];

src/Resources/contao/dca/tl_form.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use Doctrine\DBAL\Types\Types;
6+
57
$GLOBALS['TL_DCA']['tl_form']['config']['onload_callback'][] = [
68
'netzmacht.contao_form_designer.listener.dca.form',
79
'preparePalette',
@@ -17,5 +19,5 @@
1719
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form', 'getFormLayoutOptions'],
1820
'foreignKey' => 'tl_form_layout.title',
1921
'relation' => ['type' => 'belongsTo', 'load' => 'lazy'],
20-
'sql' => "int(10) unsigned NOT NULL default '0'",
22+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
2123
];

src/Resources/contao/dca/tl_form_field.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use Doctrine\DBAL\Types\Types;
6+
57
$GLOBALS['TL_DCA']['tl_form_field']['config']['onload_callback'][] = [
68
'netzmacht.contao_form_designer.listener.dca.form_field',
79
'initialize',
@@ -12,15 +14,15 @@
1214
'inputType' => 'text',
1315
'search' => true,
1416
'eval' => ['maxlength' => 255, 'tl_class' => 'long clr'],
15-
'sql' => "varchar(255) NOT NULL default ''",
17+
'sql' => ['type' => Types::STRING, 'length' => 255, 'default' => '', 'notnull' => true],
1618
];
1719

1820
$GLOBALS['TL_DCA']['tl_form_field']['fields']['controlClass'] = [
1921
'exclude' => true,
2022
'search' => true,
2123
'inputType' => 'text',
2224
'eval' => ['maxlength' => 255, 'tl_class' => 'w50'],
23-
'sql' => "varchar(255) NOT NULL default ''",
25+
'sql' => ['type' => Types::STRING, 'length' => 255, 'default' => '', 'notnull' => true],
2426
];
2527

2628
$GLOBALS['TL_DCA']['tl_form_field']['fields']['formLayout'] = [
@@ -33,7 +35,7 @@
3335
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.module', 'getFormLayoutOptions'],
3436
'foreignKey' => 'tl_form_layout.title',
3537
'relation' => ['type' => 'belongsTo', 'load' => 'lazy'],
36-
'sql' => "int(10) unsigned NOT NULL default '0'",
38+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
3739
];
3840

3941
$GLOBALS['TL_DCA']['tl_form_field']['fields']['controlTemplate'] = [

src/Resources/contao/dca/tl_form_layout.php

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare(strict_types=1);
44

55
use Contao\DC_Table;
6+
use Doctrine\DBAL\Types\Types;
67

78
$GLOBALS['TL_DCA']['tl_form_layout'] = [
89
'config' => [
@@ -87,20 +88,27 @@
8788
'id' => [
8889
'label' => ['ID'],
8990
'search' => true,
90-
'sql' => 'int(10) unsigned NOT NULL auto_increment',
91+
'sql' => [
92+
'type' => Types::INTEGER,
93+
'unsigned' => true,
94+
'autoincrement' => true,
95+
'notnull' => true,
96+
],
9197
],
9298
'pid' => [
9399
'foreignKey' => 'tl_theme.name',
94-
'sql' => "int(10) unsigned NOT NULL default '0'",
100+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
95101
'relation' => ['type' => 'belongsTo', 'load' => 'lazy'],
96102
],
97-
'tstamp' => ['sql' => "int(10) unsigned NOT NULL default '0'"],
103+
'tstamp' => [
104+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
105+
],
98106
'title' => [
99107
'exclude' => true,
100108
'inputType' => 'text',
101109
'search' => true,
102110
'eval' => ['mandatory' => true, 'maxlength' => 255, 'tl_class' => 'w50'],
103-
'sql' => "varchar(255) NOT NULL default ''",
111+
'sql' => ['type' => Types::STRING, 'length' => 255, 'default' => '', 'notnull' => true],
104112
],
105113
'type' => [
106114
'exclude' => true,
@@ -114,13 +122,19 @@
114122
'chosen' => true,
115123
'submitOnChange' => true,
116124
],
117-
'sql' => "varchar(32) NOT NULL default ''",
125+
'sql' => ['type' => Types::STRING, 'length' => 32, 'default' => '', 'notnull' => true],
118126
],
119127
'defaultLayout' => [
120128
'exclude' => true,
121129
'inputType' => 'checkbox',
122130
'eval' => ['tl_class' => 'w50'],
123-
'sql' => "char(1) NOT NULL default ''",
131+
'sql' => [
132+
'type' => Types::STRING,
133+
'length' => 1,
134+
'fixed' => true,
135+
'default' => '',
136+
'notnull' => true,
137+
],
124138
],
125139
'widgets' => [
126140
'exclude' => true,
@@ -166,42 +180,42 @@
166180
],
167181
],
168182
'eval' => ['tl_class' => 'clr long'],
169-
'sql' => 'blob NULL',
183+
'sql' => ['type' => Types::BLOB, 'notnull' => false],
170184
],
171185
'fallbackLayout' => [
172186
'exclude' => true,
173187
'inputType' => 'select',
174188
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form_layout', 'getLayoutTemplates'],
175189
'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true],
176-
'sql' => "varchar(64) NOT NULL default ''",
190+
'sql' => ['type' => Types::STRING, 'length' => 64, 'default' => '', 'notnull' => true],
177191
],
178192
'fallbackControl' => [
179193
'exclude' => true,
180194
'inputType' => 'select',
181195
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form_layout', 'getControlTemplates'],
182196
'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true],
183-
'sql' => "varchar(64) NOT NULL default ''",
197+
'sql' => ['type' => Types::STRING, 'length' => 64, 'default' => '', 'notnull' => true],
184198
],
185199
'fallbackLabel' => [
186200
'exclude' => true,
187201
'inputType' => 'select',
188202
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form_layout', 'getLabelTemplates'],
189203
'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true],
190-
'sql' => "varchar(64) NOT NULL default ''",
204+
'sql' => ['type' => Types::STRING, 'length' => 64, 'default' => '', 'notnull' => true],
191205
],
192206
'fallbackError' => [
193207
'exclude' => true,
194208
'inputType' => 'select',
195209
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form_layout', 'getErrorTemplates'],
196210
'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true],
197-
'sql' => "varchar(64) NOT NULL default ''",
211+
'sql' => ['type' => Types::STRING, 'length' => 64, 'default' => '', 'notnull' => true],
198212
],
199213
'fallbackHelp' => [
200214
'exclude' => true,
201215
'inputType' => 'select',
202216
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.form_layout', 'getHelpTemplates'],
203217
'eval' => ['tl_class' => 'w50', 'includeBlankOption' => true, 'chosen' => true],
204-
'sql' => "varchar(64) NOT NULL default ''",
218+
'sql' => ['type' => Types::STRING, 'length' => 64, 'default' => '', 'notnull' => true],
205219
],
206220
],
207221
];

src/Resources/contao/dca/tl_module.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use Doctrine\DBAL\Types\Types;
6+
57
$GLOBALS['TL_DCA']['tl_module']['config']['onload_callback'][] = [
68
'netzmacht.contao_form_designer.listener.dca.module',
79
'initialize',
@@ -17,5 +19,5 @@
1719
'options_callback' => ['netzmacht.contao_form_designer.listener.dca.module', 'getFormLayoutOptions'],
1820
'foreignKey' => 'tl_form_layout.title',
1921
'relation' => ['type' => 'belongsTo', 'load' => 'lazy'],
20-
'sql' => "int(10) unsigned NOT NULL default '0'",
22+
'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0, 'notnull' => true],
2123
];

0 commit comments

Comments
 (0)