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