Skip to content

Commit 2e0cb60

Browse files
committed
feature symfony#24277 [Serializer] Getter for extra attributes in ExtraAttributesException (mdeboer)
This PR was squashed before being merged into the 3.4 branch (closes symfony#24277). Discussion ---------- [Serializer] Getter for extra attributes in ExtraAttributesException | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes (failure unrelated) | Fixed tickets | | License | MIT This PR adds a public getter for the extra attributes in `ExtraAttributesException` and makes it easier to create custom exception messages (e.g. JSON formatted). Commits ------- cb935e7 [Serializer] Getter for extra attributes in ExtraAttributesException
2 parents 2e608f7 + cb935e7 commit 2e0cb60

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* added `AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT` context option
88
to disable throwing an `UnexpectedValueException` on a type mismatch
99
* added support for serializing `DateInterval` objects
10+
* added getter for extra attributes in `ExtraAttributesException`
1011

1112
3.3.0
1213
-----

src/Symfony/Component/Serializer/Exception/ExtraAttributesException.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,24 @@
1818
*/
1919
class ExtraAttributesException extends RuntimeException
2020
{
21+
private $extraAttributes;
22+
2123
public function __construct(array $extraAttributes, \Exception $previous = null)
2224
{
2325
$msg = sprintf('Extra attributes are not allowed ("%s" are unknown).', implode('", "', $extraAttributes));
2426

27+
$this->extraAttributes = $extraAttributes;
28+
2529
parent::__construct($msg, 0, $previous);
2630
}
31+
32+
/**
33+
* Get the extra attributes that are not allowed.
34+
*
35+
* @return array
36+
*/
37+
public function getExtraAttributes()
38+
{
39+
return $this->extraAttributes;
40+
}
2741
}

0 commit comments

Comments
 (0)