assets.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\Asset\Context\RequestStackContext;
  12. use Symfony\Component\Asset\Package;
  13. use Symfony\Component\Asset\Packages;
  14. use Symfony\Component\Asset\PathPackage;
  15. use Symfony\Component\Asset\UrlPackage;
  16. use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
  17. use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;
  18. use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy;
  19. use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
  20. return static function (ContainerConfigurator $container) {
  21. $container->parameters()
  22. ->set('asset.request_context.base_path', null)
  23. ->set('asset.request_context.secure', null)
  24. ;
  25. $container->services()
  26. ->set('assets.packages', Packages::class)
  27. ->args([
  28. service('assets.empty_package'),
  29. [],
  30. ])
  31. ->alias(Packages::class, 'assets.packages')
  32. ->set('assets.empty_package', Package::class)
  33. ->args([
  34. service('assets.empty_version_strategy'),
  35. ])
  36. ->set('assets.context', RequestStackContext::class)
  37. ->args([
  38. service('request_stack'),
  39. param('asset.request_context.base_path'),
  40. param('asset.request_context.secure'),
  41. ])
  42. ->set('assets.path_package', PathPackage::class)
  43. ->abstract()
  44. ->args([
  45. abstract_arg('base path'),
  46. abstract_arg('version strategy'),
  47. service('assets.context'),
  48. ])
  49. ->set('assets.url_package', UrlPackage::class)
  50. ->abstract()
  51. ->args([
  52. abstract_arg('base URLs'),
  53. abstract_arg('version strategy'),
  54. service('assets.context'),
  55. ])
  56. ->set('assets.static_version_strategy', StaticVersionStrategy::class)
  57. ->abstract()
  58. ->args([
  59. abstract_arg('version'),
  60. abstract_arg('format'),
  61. ])
  62. ->set('assets.empty_version_strategy', EmptyVersionStrategy::class)
  63. ->set('assets.json_manifest_version_strategy', JsonManifestVersionStrategy::class)
  64. ->abstract()
  65. ->args([
  66. abstract_arg('manifest path'),
  67. ])
  68. ->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class)
  69. ->abstract()
  70. ->args([
  71. abstract_arg('manifest url'),
  72. service('http_client'),
  73. ])
  74. ;
  75. };