[Serializer] Getter for extra attributes in ExtraAttributesException

This commit is contained in:
Maarten de Boer 2017-09-21 14:46:00 +02:00 committed by Maxime Steinhausser
parent 701d41cc33
commit cb935e789e
2 changed files with 15 additions and 0 deletions

View File

@ -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
-----

View File

@ -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;
}
}