Skip to content

Commit 5edd5ef

Browse files
committed
minor #11794 Update name of arguments in interface DataMapperInterface methods (gdembowski)
This PR was submitted for the 4.3 branch but it was merged into the 3.4 branch instead (closes #11794). Discussion ---------- Update name of arguments in interface DataMapperInterface methods <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- d51657f Update name of argument
2 parents cd5d633 + d51657f commit 5edd5ef

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

form/data_mappers.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,38 @@ in your form type::
9696
// ...
9797

9898
/**
99-
* @param Color|null $data
99+
* @param Color|null $viewData
100100
*/
101-
public function mapDataToForms($data, $forms)
101+
public function mapDataToForms($viewData, $forms)
102102
{
103103
// there is no data yet, so nothing to prepopulate
104-
if (null === $data) {
104+
if (null === $viewData) {
105105
return;
106106
}
107107

108108
// invalid data type
109-
if (!$data instanceof Color) {
110-
throw new UnexpectedTypeException($data, Color::class);
109+
if (!$viewData instanceof Color) {
110+
throw new UnexpectedTypeException($viewData, Color::class);
111111
}
112112

113113
/** @var FormInterface[] $forms */
114114
$forms = iterator_to_array($forms);
115115

116116
// initialize form field values
117-
$forms['red']->setData($data->getRed());
118-
$forms['green']->setData($data->getGreen());
119-
$forms['blue']->setData($data->getBlue());
117+
$forms['red']->setData($viewData->getRed());
118+
$forms['green']->setData($viewData->getGreen());
119+
$forms['blue']->setData($viewData->getBlue());
120120
}
121121

122-
public function mapFormsToData($forms, &$data)
122+
public function mapFormsToData($forms, &$viewData)
123123
{
124124
/** @var FormInterface[] $forms */
125125
$forms = iterator_to_array($forms);
126126

127127
// as data is passed by reference, overriding it will change it in
128128
// the form object as well
129129
// beware of type inconsistency, see caution below
130-
$data = new Color(
130+
$viewData = new Color(
131131
$forms['red']->getData(),
132132
$forms['green']->getData(),
133133
$forms['blue']->getData()

0 commit comments

Comments
 (0)