fragment_renderer.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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 Symfony\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler;
  12. use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
  13. use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
  14. use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer;
  15. use Symfony\Component\HttpKernel\Fragment\SsiFragmentRenderer;
  16. return static function (ContainerConfigurator $container) {
  17. $container->parameters()
  18. ->set('fragment.renderer.hinclude.global_template', null)
  19. ->set('fragment.path', '/_fragment')
  20. ;
  21. $container->services()
  22. ->set('fragment.handler', LazyLoadingFragmentHandler::class)
  23. ->args([
  24. abstract_arg('fragment renderer locator'),
  25. service('request_stack'),
  26. param('kernel.debug'),
  27. ])
  28. ->set('fragment.renderer.inline', InlineFragmentRenderer::class)
  29. ->args([service('http_kernel'), service('event_dispatcher')])
  30. ->call('setFragmentPath', [param('fragment.path')])
  31. ->tag('kernel.fragment_renderer', ['alias' => 'inline'])
  32. ->set('fragment.renderer.hinclude', HIncludeFragmentRenderer::class)
  33. ->args([
  34. service('twig')->nullOnInvalid(),
  35. service('uri_signer'),
  36. param('fragment.renderer.hinclude.global_template'),
  37. ])
  38. ->call('setFragmentPath', [param('fragment.path')])
  39. ->set('fragment.renderer.esi', EsiFragmentRenderer::class)
  40. ->args([
  41. service('esi')->nullOnInvalid(),
  42. service('fragment.renderer.inline'),
  43. service('uri_signer'),
  44. ])
  45. ->call('setFragmentPath', [param('fragment.path')])
  46. ->tag('kernel.fragment_renderer', ['alias' => 'esi'])
  47. ->set('fragment.renderer.ssi', SsiFragmentRenderer::class)
  48. ->args([
  49. service('ssi')->nullOnInvalid(),
  50. service('fragment.renderer.inline'),
  51. service('uri_signer'),
  52. ])
  53. ->call('setFragmentPath', [param('fragment.path')])
  54. ->tag('kernel.fragment_renderer', ['alias' => 'ssi'])
  55. ;
  56. };