[Serializer] Getter for extra attributes in ExtraAttributesException
This commit is contained in:
parent
701d41cc33
commit
cb935e789e
@ -7,6 +7,7 @@ CHANGELOG
|
||||
* added `AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT` context option
|
||||
to disable throwing an `UnexpectedValueException` on a type mismatch
|
||||
* added support for serializing `DateInterval` objects
|
||||
* added getter for extra attributes in `ExtraAttributesException`
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
@ -18,10 +18,24 @@ namespace Symfony\Component\Serializer\Exception;
|
||||
*/
|
||||
class ExtraAttributesException extends RuntimeException
|
||||
{
|
||||
private $extraAttributes;
|
||||
|
||||
public function __construct(array $extraAttributes, \Exception $previous = null)
|
||||
{
|
||||
$msg = sprintf('Extra attributes are not allowed ("%s" are unknown).', implode('", "', $extraAttributes));
|
||||
|
||||
$this->extraAttributes = $extraAttributes;
|
||||
|
||||
parent::__construct($msg, 0, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extra attributes that are not allowed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtraAttributes()
|
||||
{
|
||||
return $this->extraAttributes;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user