| @@ 26-70 (lines=45) @@ | ||
| 23 | * |
|
| 24 | * @deprecated since FOSRestBundle 3.1, use the option `fos_rest.serializer.disable_jms_handlers` to avoid relying on it. |
|
| 25 | */ |
|
| 26 | class JMSHandlerRegistry implements HandlerRegistryInterface |
|
| 27 | { |
|
| 28 | private $registry; |
|
| 29 | ||
| 30 | public function __construct(HandlerRegistryInterface $registry) |
|
| 31 | { |
|
| 32 | $this->registry = $registry; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * {@inheritdoc} |
|
| 37 | */ |
|
| 38 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void |
|
| 39 | { |
|
| 40 | $this->registry->registerSubscribingHandler($handler); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function registerHandler($direction, $typeName, $format, $handler): void |
|
| 47 | { |
|
| 48 | $this->registry->registerHandler($direction, $typeName, $format, $handler); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function getHandler($direction, $typeName, $format) |
|
| 55 | { |
|
| 56 | $first = true; |
|
| 57 | do { |
|
| 58 | $handler = $this->registry->getHandler($direction, $typeName, $format); |
|
| 59 | if (null !== $handler) { |
|
| 60 | if (!$first) { |
|
| 61 | @trigger_error(sprintf('Relying on the custom registry %s to inherit the JMS handler of type `%s` is deprecated since FOSRestBundle 3.1. It will be removed in version 4.0. Use the option `fos_rest.serializer.disable_custom_jms_registry` to disable it.', __CLASS__, $typeName), E_USER_DEPRECATED); |
|
| 62 | } |
|
| 63 | ||
| 64 | return $handler; |
|
| 65 | } |
|
| 66 | ||
| 67 | $first = false; |
|
| 68 | } while ($typeName = get_parent_class($typeName)); |
|
| 69 | } |
|
| 70 | } |
|
| 71 | ||
| @@ 26-70 (lines=45) @@ | ||
| 23 | * |
|
| 24 | * @deprecated since FOSRestBundle 3.1, use the option `fos_rest.serializer.disable_custom_jms_registry` to avoid relying on it. |
|
| 25 | */ |
|
| 26 | final class JMSHandlerRegistryV2 implements HandlerRegistryInterface |
|
| 27 | { |
|
| 28 | private $registry; |
|
| 29 | ||
| 30 | public function __construct(HandlerRegistryInterface $registry) |
|
| 31 | { |
|
| 32 | $this->registry = $registry; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * {@inheritdoc} |
|
| 37 | */ |
|
| 38 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void |
|
| 39 | { |
|
| 40 | $this->registry->registerSubscribingHandler($handler); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function registerHandler(int $direction, string $typeName, string $format, $handler): void |
|
| 47 | { |
|
| 48 | $this->registry->registerHandler($direction, $typeName, $format, $handler); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | */ |
|
| 54 | public function getHandler(int $direction, string $typeName, string $format) |
|
| 55 | { |
|
| 56 | $first = true; |
|
| 57 | do { |
|
| 58 | $handler = $this->registry->getHandler($direction, $typeName, $format); |
|
| 59 | if (null !== $handler) { |
|
| 60 | if (!$first) { |
|
| 61 | @trigger_error(sprintf('Relying on the custom registry %s to inherit the JMS handler of type `%s` is deprecated since FOSRestBundle 3.1. It will be removed in version 4.0. Use the option `fos_rest.serializer.disable_custom_jms_registry` to disable it.', __CLASS__, $typeName), E_USER_DEPRECATED); |
|
| 62 | } |
|
| 63 | ||
| 64 | return $handler; |
|
| 65 | } |
|
| 66 | ||
| 67 | $first = false; |
|
| 68 | } while ($typeName = get_parent_class($typeName)); |
|
| 69 | } |
|
| 70 | } |
|
| 71 | ||