vendor/jms/serializer-bundle/JMSSerializerBundle.php line 18

Open in your IDE?
  1. <?php
  2. namespace JMS\SerializerBundle;
  3. use JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceMapPass;
  4. use JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersLocatorPass;
  5. use JMS\SerializerBundle\DependencyInjection\Compiler\CustomHandlersPass;
  6. use JMS\SerializerBundle\DependencyInjection\Compiler\DoctrinePass;
  7. use JMS\SerializerBundle\DependencyInjection\Compiler\ExpressionFunctionProviderPass;
  8. use JMS\SerializerBundle\DependencyInjection\Compiler\FormErrorHandlerTranslationDomainPass;
  9. use JMS\SerializerBundle\DependencyInjection\Compiler\RegisterEventListenersAndSubscribersPass;
  10. use JMS\SerializerBundle\DependencyInjection\Compiler\ServiceMapPass;
  11. use JMS\SerializerBundle\DependencyInjection\Compiler\TwigExtensionPass;
  12. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\HttpKernel\Bundle\Bundle;
  15. class JMSSerializerBundle extends Bundle
  16. {
  17.     public function build(ContainerBuilder $builder)
  18.     {
  19.         $builder->addCompilerPass($this->getServiceMapPass('jms_serializer.serialization_visitor''format',
  20.             function (ContainerBuilder $container$def) {
  21.                 $container->getDefinition('jms_serializer.serializer')->replaceArgument(2$def);
  22.             }
  23.         ));
  24.         $builder->addCompilerPass($this->getServiceMapPass('jms_serializer.deserialization_visitor''format',
  25.             function (ContainerBuilder $container$def) {
  26.                 $container->getDefinition('jms_serializer.serializer')->replaceArgument(3$def);
  27.             }
  28.         ));
  29.         $builder->addCompilerPass(new FormErrorHandlerTranslationDomainPass());
  30.         $builder->addCompilerPass(new TwigExtensionPass());
  31.         $builder->addCompilerPass(new ExpressionFunctionProviderPass());
  32.         $builder->addCompilerPass(new DoctrinePass());
  33.         $builder->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_OPTIMIZE);
  34.         $builder->addCompilerPass(new CustomHandlersPass(), PassConfig::TYPE_OPTIMIZE);
  35.     }
  36.     private function getServiceMapPass($tagName$keyAttributeName$callable)
  37.     {
  38.         if (class_exists('JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceMapPass')) {
  39.             return new LazyServiceMapPass($tagName$keyAttributeName$callable);
  40.         }
  41.         return new ServiceMapPass($tagName$keyAttributeName$callable);
  42.     }
  43. }