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