@@ -12,6 +12,7 @@ application there could be more tags available provided by third-party bundles:
12
12
Tag Name Usage
13
13
======================================== ========================================================================
14
14
`auto_alias `_ Define aliases based on the value of container parameters
15
+ `assets.package `_ Add an asset package
15
16
`console.command `_ Add a command
16
17
`container.hot_path `_ Add to list of always needed services
17
18
`container.no_preload `_ Remove a class from the list of classes preloaded by PHP
@@ -50,6 +51,53 @@ Tag Name Usage
50
51
`validator.initializer `_ Register a service that initializes objects before validation
51
52
======================================== ========================================================================
52
53
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
+ The `package ` attribute of the tag is required to name the package.
61
+
62
+ .. configuration-block ::
63
+
64
+ .. code-block :: yaml
65
+
66
+ services :
67
+ App\Assets\AvatarPackage :
68
+ tags :
69
+ - { name: assets.package, package: avatars }
70
+
71
+ .. code-block :: xml
72
+
73
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
74
+ <container xmlns =" http://symfony.com/schema/dic/services"
75
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
76
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
77
+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
78
+
79
+ <services >
80
+ <service id =" App\Assets\AvatarPackage" >
81
+ <tag name =" assets.package" package =" avatars" />
82
+ </service >
83
+ </services >
84
+ </container >
85
+
86
+ .. code-block :: php
87
+
88
+ use App\Assets\AvatarPackage;
89
+
90
+ $container
91
+ ->register(AvatarPackage::class)
92
+ ->addTag('assets.package', ['package' => 'avatars'])
93
+ ;
94
+
95
+ Now you can use the ``avatars `` package in your templates:
96
+
97
+ .. code-block :: html+twig
98
+
99
+ <img src="{{ asset('...', 'avatars') }}">
100
+
53
101
auto_alias
54
102
----------
55
103
0 commit comments