@@ -11,13 +11,6 @@ application there could be more tags available provided by third-party bundles:
1111======================================== ========================================================================
1212Tag Name Usage
1313======================================== ========================================================================
14- `assetic.asset `_ Register an asset to the current asset manager
15- `assetic.factory_worker `_ Add a factory worker
16- `assetic.filter `_ Register a filter
17- `assetic.formula_loader `_ Add a formula loader to the current asset manager
18- `assetic.formula_resource `_ Adds a resource to the current asset manager
19- `assetic.templating.php `_ Remove this service if PHP templating is disabled
20- `assetic.templating.twig `_ Remove this service if Twig templating is disabled
2114`auto_alias `_ Define aliases based on the value of container parameters
2215`console.command `_ Add a command
2316`controller.argument_value_resolver `_ Register a value resolver for controller arguments such as ``Request ``
@@ -52,182 +45,6 @@ Tag Name Usage
5245`validator.initializer `_ Register a service that initializes objects before validation
5346======================================== ========================================================================
5447
55- assetic.asset
56- -------------
57-
58- **Purpose **: Register an asset with the current asset manager
59-
60- assetic.factory_worker
61- ----------------------
62-
63- **Purpose **: Add a factory worker
64-
65- A Factory worker is a class implementing ``Assetic\Factory\Worker\WorkerInterface ``.
66- Its ``process($asset) `` method is called for each asset after asset creation.
67- You can modify an asset or even return a new one.
68-
69- In order to add a new worker, first create a class::
70-
71- use Assetic\Asset\AssetInterface;
72- use Assetic\Factory\Worker\WorkerInterface;
73-
74- class MyWorker implements WorkerInterface
75- {
76- public function process(AssetInterface $asset)
77- {
78- // ... change $asset or return a new one
79- }
80-
81- }
82-
83- And then register it as a tagged service:
84-
85- ..configuration-block ::
86-
87- ..code-block ::yaml
88-
89- services :
90- App\Assetic\CustomWorker :
91- tags :[assetic.factory_worker]
92-
93- ..code-block ::xml
94-
95- <?xml version =" 1.0" encoding =" UTF-8" ?>
96- <container xmlns =" http://symfony.com/schema/dic/services"
97- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
98- xsi : schemaLocation =" http://symfony.com/schema/dic/services
99- http://symfony.com/schema/dic/services/services-1.0.xsd" >
100-
101- <services >
102- <service id =" App\Assetic\CustomWorker" >
103- <tag name =" assetic.factory_worker" />
104- </service >
105- </services >
106- </container >
107-
108- ..code-block ::php
109-
110- use App\Assetic\CustomWorker;
111-
112- $container
113- ->register(CustomWorker::class)
114- ->addTag('assetic.factory_worker')
115- ;
116-
117- assetic.filter
118- --------------
119-
120- **Purpose **: Register a filter
121-
122- AsseticBundle uses this tag to register common filters. You can also use
123- this tag to register your own filters.
124-
125- First, you need to create a filter::
126-
127- use Assetic\Asset\AssetInterface;
128- use Assetic\Filter\FilterInterface;
129-
130- class MyFilter implements FilterInterface
131- {
132- public function filterLoad(AssetInterface $asset)
133- {
134- $asset->setContent('alert("yo");' . $asset->getContent());
135- }
136-
137- public function filterDump(AssetInterface $asset)
138- {
139- // ...
140- }
141- }
142-
143- Second, define a service:
144-
145- ..configuration-block ::
146-
147- ..code-block ::yaml
148-
149- services :
150- App\Assetic\CustomFilter :
151- tags :
152- -{ name: assetic.filter, alias: my_filter }
153-
154- ..code-block ::xml
155-
156- <?xml version =" 1.0" encoding =" UTF-8" ?>
157- <container xmlns =" http://symfony.com/schema/dic/services"
158- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
159- xsi : schemaLocation =" http://symfony.com/schema/dic/services
160- http://symfony.com/schema/dic/services/services-1.0.xsd" >
161-
162- <services >
163- <service id =" App\Assetic\CustomFilter" >
164- <tag name =" assetic.filter" alias =" my_filter" />
165- </service >
166- </services >
167- </container >
168-
169- ..code-block ::php
170-
171- use App\Assetic\CustomFilter;
172-
173- $container
174- ->register(CustomFilter::class)
175- ->addTag('assetic.filter', array('alias' => 'my_filter'))
176- ;
177-
178- Finally, apply the filter:
179-
180- ..code-block ::twig
181-
182- {% javascripts
183- '@AcmeBaseBundle/Resources/public/js/global.js'
184- filter='my_filter'
185- %}
186- <script src="{{ asset_url }}"></script>
187- {% endjavascripts %}
188-
189- You can also apply your filter via the ``assetic.filters.my_filter.apply_to ``
190- config option as it's described here::doc: `/frontend/assetic/apply_to_option `.
191- In order to do that, you must define your filter service in a separate xml
192- config file and point to this file's path via the ``assetic.filters.my_filter.resource ``
193- configuration key.
194-
195- assetic.formula_loader
196- ----------------------
197-
198- **Purpose **: Add a formula loader to the current asset manager
199-
200- A Formula loader is a class implementing
201- ``Assetic\\Factory\Loader\\FormulaLoaderInterface `` interface. This class
202- is responsible for loading assets from a particular kind of resources (for
203- instance, twig template). Assetic ships loaders for PHP and Twig templates.
204-
205- An ``alias `` attribute defines the name of the loader.
206-
207- assetic.formula_resource
208- ------------------------
209-
210- **Purpose **: Adds a resource to the current asset manager
211-
212- A resource is something formulae can be loaded from. For instance, Twig
213- templates are resources.
214-
215- assetic.templating.php
216- ----------------------
217-
218- **Purpose **: Remove this service if PHP templating is disabled
219-
220- The tagged service will be removed from the container if the
221- ``framework.templating.engines `` config section does not contain php.
222-
223- assetic.templating.twig
224- -----------------------
225-
226- **Purpose **: Remove this service if Twig templating is disabled
227-
228- The tagged service will be removed from the container if
229- ``framework.templating.engines `` config section does not contain ``twig ``.
230-
23148auto_alias
23249----------
23350