Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb718c0

Browse files
committed
Catch only UninitializedPropertyException when getting a value per PropertyAcessor
1 parenta975d5e commitdb718c0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

‎src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ public function mapDataToForms($data, $forms)
5252
$form->setData($this->propertyAccessor->getValue($data,$propertyPath));
5353
}catch (AccessException$e) {
5454
// Skip unitialized properties on $data
55-
if (!$einstanceof UninitializedPropertyException
56-
// For versions without UninitializedPropertyException check the exception message
57-
&& (class_exists(UninitializedPropertyException::class) ||false ===strpos($e->getMessage(),'You should initialize it'))
58-
) {
59-
throw$e;
60-
}
55+
$this->catchUninitializedPropertyException($e);
6156
}
6257
}else {
6358
$form->setData($config->getData());
@@ -118,7 +113,24 @@ private function getPropertyValue($data, $propertyPath)
118113
try {
119114
return$this->propertyAccessor->getValue($data,$propertyPath);
120115
}catch (AccessException$e) {
116+
// The following line might be removed in future versions
117+
// See https://github.com/symfony/symfony/issues/36754
118+
$this->catchUninitializedPropertyException($e);
119+
121120
returnnull;
122121
}
123122
}
123+
124+
/**
125+
* Throw everything but UninitializedPropertyException.
126+
*/
127+
privatefunctioncatchUninitializedPropertyException(AccessException$e)
128+
{
129+
if (!$einstanceof UninitializedPropertyException
130+
// For versions without UninitializedPropertyException check the exception message
131+
&& (class_exists(UninitializedPropertyException::class) ||false ===strpos($e->getMessage(),'You should initialize it'))
132+
) {
133+
throw$e;
134+
}
135+
}
124136
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp