FriendsOfSymfony /
FOSRestBundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the FOSRestBundle package. |
||
| 5 | * |
||
| 6 | * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace FOS\RestBundle\Serializer; |
||
| 13 | |||
| 14 | use JMS\Serializer\Handler\SubscribingHandlerInterface; |
||
| 15 | use JMS\Serializer\Handler\HandlerRegistryInterface; |
||
| 16 | use Symfony\Component\ErrorHandler\Exception\FlattenException; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Search in the class parents to find an adapted handler. |
||
| 20 | * |
||
| 21 | * @author Ener-Getick <[email protected]> |
||
| 22 | * |
||
| 23 | * @internal do not depend on this class directly |
||
| 24 | * |
||
| 25 | * @deprecated since FOSRestBundle 3.1, use the option `fos_rest.serializer.disable_jms_handlers` to avoid relying on it. |
||
| 26 | */ |
||
| 27 | View Code Duplication | class JMSHandlerRegistry implements HandlerRegistryInterface |
|
| 28 | { |
||
| 29 | private $registry; |
||
| 30 | |||
| 31 | public function __construct(HandlerRegistryInterface $registry) |
||
| 32 | { |
||
| 33 | $this->registry = $registry; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void |
||
| 40 | { |
||
| 41 | $this->registry->registerSubscribingHandler($handler); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritdoc} |
||
| 46 | */ |
||
| 47 | public function registerHandler($direction, $typeName, $format, $handler): void |
||
| 48 | { |
||
| 49 | $this->registry->registerHandler($direction, $typeName, $format, $handler); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | public function getHandler($direction, $typeName, $format) |
||
| 56 | { |
||
| 57 | $first = true; |
||
| 58 | do { |
||
| 59 | $handler = $this->registry->getHandler($direction, $typeName, $format); |
||
| 60 | if (null !== $handler) { |
||
| 61 | if (!$first) { |
||
| 62 | @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); |
||
|
0 ignored issues
–
show
|
|||
| 63 | } |
||
| 64 | |||
| 65 | return $handler; |
||
| 66 | } |
||
| 67 | |||
| 68 | $first = false; |
||
| 69 | } while ($typeName = get_parent_class($typeName)); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |
If you suppress an error, we recommend checking for the error condition explicitly: