@@ -12,6 +12,7 @@ application there could be more tags available provided by third-party bundles:
1212Tag Name Usage
1313======================================== ========================================================================
1414`auto_alias `_ Define aliases based on the value of container parameters
15+ `assets.package `_ Add an asset package
1516`console.command `_ Add a command
1617`container.hot_path `_ Add to list of always needed services
1718`container.no_preload `_ Remove a class from the list of classes preloaded by PHP
@@ -50,6 +51,57 @@ Tag Name Usage
5051`validator.initializer `_ Register a service that initializes objects before validation
5152======================================== ========================================================================
5253
54+ assets.package
55+ --------------
56+
57+ **Purpose **: Add an asset package to the application
58+
59+ This is an alternative way to declare a package in :doc: `/components/asset `.
60+
61+ The name of the package is set in this order:
62+ * first, the `package ` attribute of the tag
63+ * then, the value returned by the static method `getDefaultPackageName() ` if defined
64+ * finally, the service name
65+
66+ .. configuration-block ::
67+
68+ .. code-block :: yaml
69+
70+ services :
71+ App\Assets\AvatarPackage :
72+ tags :
73+ - { name: assets.package, package: avatars }
74+
75+ .. code-block :: xml
76+
77+ <?xml version =" 1.0" encoding =" UTF-8" ?>
78+ <container xmlns =" http://symfony.com/schema/dic/services"
79+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
80+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
81+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
82+
83+ <services >
84+ <service id =" App\Assets\AvatarPackage" >
85+ <tag name =" assets.package" package =" avatars" />
86+ </service >
87+ </services >
88+ </container >
89+
90+ .. code-block :: php
91+
92+ use App\Assets\AvatarPackage;
93+
94+ $container
95+ ->register(AvatarPackage::class)
96+ ->addTag('assets.package', ['package' => 'avatars'])
97+ ;
98+
99+ Now you can use the ``avatars `` package in your templates:
100+
101+ .. code-block :: html+twig
102+
103+ <img src="{{ asset('...', 'avatars') }}">
104+
53105auto_alias
54106----------
55107
0 commit comments