vendor/drosalys/api-bundle/src/DrosalysApiBundle.php line 32

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the drosalys/api-bundle package.
  4. *
  5. * (c) Benjamin Georgeault
  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 Drosalys\Bundle\ApiBundle;
  11. use Drosalys\Bundle\ApiBundle\Action\ActionRetriever;
  12. use Drosalys\Bundle\ApiBundle\ApiDoc\Model\ModelRegistry;
  13. use Drosalys\Bundle\ApiBundle\ApiDoc\RouteDescriber\AbstractDescriber;
  14. use Drosalys\Bundle\ApiBundle\DependencyInjection\Compiler\EntityIdApiDocPass;
  15. use Drosalys\Bundle\ApiBundle\DependencyInjection\Compiler\SymfonySerializerPass;
  16. use Drosalys\Bundle\ApiBundle\Persister\PersisterHandler\PersisterHandlerInterface;
  17. use Drosalys\Bundle\ApiBundle\Response\ResponseHandler\AbstractResponseHandler;
  18. use Drosalys\Bundle\ApiBundle\Response\ResponseHandler\ResponseHandlerInterface;
  19. use Drosalys\Bundle\ApiBundle\Serializer\SerializerInterface;
  20. use Symfony\Component\DependencyInjection\ContainerBuilder;
  21. use Symfony\Component\DependencyInjection\Reference;
  22. use Symfony\Component\HttpKernel\Bundle\Bundle;
  23. /**
  24. * Class DrosalysApiBundle
  25. *
  26. * @author Benjamin Georgeault
  27. */
  28. class DrosalysApiBundle extends Bundle
  29. {
  30. public function build(ContainerBuilder $container)
  31. {
  32. $container->addCompilerPass(new SymfonySerializerPass());
  33. $container->addCompilerPass(new EntityIdApiDocPass());
  34. $container->registerForAutoconfiguration(AbstractDescriber::class)
  35. ->addMethodCall('setActionRetriever', [
  36. new Reference(ActionRetriever::class),
  37. ])
  38. ->addMethodCall('setDrosalysModelRegistry', [
  39. new Reference(ModelRegistry::class),
  40. ])
  41. ;
  42. $container->registerForAutoconfiguration(AbstractResponseHandler::class)
  43. ->addMethodCall('setSerializer', [
  44. new Reference(SerializerInterface::class),
  45. ])
  46. ;
  47. $container->registerForAutoconfiguration(ResponseHandlerInterface::class)
  48. ->addTag('drosalys_api.response.response_handler')
  49. ;
  50. $container->registerForAutoconfiguration(PersisterHandlerInterface::class)
  51. ->addTag('drosalys_api.persister.persister_handler')
  52. ;
  53. }
  54. }