-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from acrobat/normalizer-bc-layer
Ported the removed DefaultMessageNormalizer to the BernardBundle
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Bernard\BernardBundle\Normalizer; | ||
|
||
use Assert\Assertion; | ||
use Bernard\Message\DefaultMessage; | ||
use Bernard\Normalizer\PlainMessageNormalizer; | ||
|
||
class DefaultMessageNormalizer extends PlainMessageNormalizer | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function normalize($object, $format = null, array $context = []) | ||
{ | ||
@trigger_error('The '.__CLASS__.' class is deprecated and will removed in version 3.0. Use '.PlainMessageNormalizer::class.' instead.', E_USER_DEPRECATED); | ||
|
||
parent::normalize($object, $format, $context); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function denormalize($data, $class, $format = null, array $context = []) | ||
{ | ||
@trigger_error('The '.__CLASS__.' class is deprecated and will removed in version 3.0. Use '.PlainMessageNormalizer::class.' instead.', E_USER_DEPRECATED); | ||
|
||
Assertion::notEmptyKey($data, 'name'); | ||
Assertion::keyExists($data, 'arguments'); | ||
Assertion::isArray($data['arguments']); | ||
|
||
return new DefaultMessage($data['name'], $data['arguments']); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsDenormalization($data, $type, $format = null) | ||
{ | ||
return $type === DefaultMessage::class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsNormalization($data, $format = null) | ||
{ | ||
return $data instanceof DefaultMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters