| @@ 25-69 (lines=45) @@ | ||
| 22 | * |
|
| 23 | * @internal do not depend on this class directly |
|
| 24 | */ |
|
| 25 | class JMSHandlerRegistry implements HandlerRegistryInterface |
|
| 26 | { |
|
| 27 | private $registry; |
|
| 28 | ||
| 29 | public function __construct(HandlerRegistryInterface $registry) |
|
| 30 | { |
|
| 31 | $this->registry = $registry; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|
| 36 | */ |
|
| 37 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler) |
|
| 38 | { |
|
| 39 | return $this->registry->registerSubscribingHandler($handler); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * {@inheritdoc} |
|
| 44 | */ |
|
| 45 | public function registerHandler($direction, $typeName, $format, $handler) |
|
| 46 | { |
|
| 47 | return $this->registry->registerHandler($direction, $typeName, $format, $handler); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * {@inheritdoc} |
|
| 52 | */ |
|
| 53 | public function getHandler($direction, $typeName, $format) |
|
| 54 | { |
|
| 55 | $first = true; |
|
| 56 | do { |
|
| 57 | $handler = $this->registry->getHandler($direction, $typeName, $format); |
|
| 58 | if (null !== $handler) { |
|
| 59 | if (!$first && FlattenException::class !== $typeName) { |
|
| 60 | @trigger_error(sprintf('The behavior of %s is deprecated since FOSRestBundle 2.8. In version 3.0, it will only force JMS Serializer to use the %s handler when possible. You should not rely on it for the parent type "%s".', __CLASS__, FlattenException::class, $typeName), E_USER_DEPRECATED); |
|
| 61 | } |
|
| 62 | ||
| 63 | return $handler; |
|
| 64 | } |
|
| 65 | ||
| 66 | $first = false; |
|
| 67 | } while ($typeName = get_parent_class($typeName)); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 25-69 (lines=45) @@ | ||
| 22 | * |
|
| 23 | * @internal do not depend on this class directly |
|
| 24 | */ |
|
| 25 | final class JMSHandlerRegistryV2 implements HandlerRegistryInterface |
|
| 26 | { |
|
| 27 | private $registry; |
|
| 28 | ||
| 29 | public function __construct(HandlerRegistryInterface $registry) |
|
| 30 | { |
|
| 31 | $this->registry = $registry; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * {@inheritdoc} |
|
| 36 | */ |
|
| 37 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void |
|
| 38 | { |
|
| 39 | $this->registry->registerSubscribingHandler($handler); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * {@inheritdoc} |
|
| 44 | */ |
|
| 45 | public function registerHandler(int $direction, string $typeName, string $format, $handler): void |
|
| 46 | { |
|
| 47 | $this->registry->registerHandler($direction, $typeName, $format, $handler); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * {@inheritdoc} |
|
| 52 | */ |
|
| 53 | public function getHandler(int $direction, string $typeName, string $format) |
|
| 54 | { |
|
| 55 | $first = true; |
|
| 56 | do { |
|
| 57 | $handler = $this->registry->getHandler($direction, $typeName, $format); |
|
| 58 | if (null !== $handler) { |
|
| 59 | if (!$first && FlattenException::class !== $typeName) { |
|
| 60 | @trigger_error(sprintf('The behavior of %s is deprecated since FOSRestBundle 2.8. In version 3.0, it will only force JMS Serializer to use the %s handler when possible. You should not rely on it for the parent type "%s".', __CLASS__, FlattenException::class, $typeName), E_USER_DEPRECATED); |
|
| 61 | } |
|
| 62 | ||
| 63 | return $handler; |
|
| 64 | } |
|
| 65 | ||
| 66 | $first = false; |
|
| 67 | } while ($typeName = get_parent_class($typeName)); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||