vendor/friendsofsymfony/rest-bundle/Serializer/JMSHandlerRegistry.php line 55

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSRestBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace FOS\RestBundle\Serializer;
  11. use JMS\Serializer\Handler\SubscribingHandlerInterface;
  12. use JMS\Serializer\Handler\HandlerRegistryInterface;
  13. /**
  14.  * Search in the class parents to find an adapted handler.
  15.  *
  16.  * @author Ener-Getick <egetick@gmail.com>
  17.  *
  18.  * @internal do not depend on this class directly
  19.  */
  20. class JMSHandlerRegistry implements HandlerRegistryInterface
  21. {
  22.     private $registry;
  23.     public function __construct(HandlerRegistryInterface $registry)
  24.     {
  25.         $this->registry $registry;
  26.     }
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     public function registerSubscribingHandler(SubscribingHandlerInterface $handler)
  31.     {
  32.         return $this->registry->registerSubscribingHandler($handler);
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function registerHandler($direction$typeName$format$handler)
  38.     {
  39.         return $this->registry->registerHandler($direction$typeName$format$handler);
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function getHandler($direction$typeName$format)
  45.     {
  46.         do {
  47.             $handler $this->registry->getHandler($direction$typeName$format);
  48.             if (null !== $handler) {
  49.                 return $handler;
  50.             }
  51.         } while ($typeName get_parent_class($typeName));
  52.     }
  53. }