Skip to content

remove assetic dic tags. Fix #7274 #7397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 0 additions & 186 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ may also be tags in other bundles you use that aren't listed here.
======================================== ========================================================================
Tag Name Usage
======================================== ========================================================================
`assetic.asset`_ Register an asset to the current asset manager
`assetic.factory_worker`_ Add a factory worker
`assetic.filter`_ Register a filter
`assetic.formula_loader`_ Add a formula loader to the current asset manager
`assetic.formula_resource`_ Adds a resource to the current asset manager
`assetic.templating.php`_ Remove this service if PHP templating is disabled
`assetic.templating.twig`_ Remove this service if Twig templating is disabled
`auto_alias`_ Define aliases based on the value of container parameters
`console.command`_ Add a command
`data_collector`_ Create a class that collects custom data for the profiler
Expand Down Expand Up @@ -55,185 +48,6 @@ Tag Name Usage
`validator.initializer`_ Register a service that initializes objects before validation
======================================== ========================================================================

assetic.asset
-------------

**Purpose**: Register an asset with the current asset manager

assetic.factory_worker
----------------------

**Purpose**: Add a factory worker

A Factory worker is a class implementing ``Assetic\Factory\Worker\WorkerInterface``.
Its ``process($asset)`` method is called for each asset after asset creation.
You can modify an asset or even return a new one.

In order to add a new worker, first create a class::

use Assetic\Asset\AssetInterface;
use Assetic\Factory\Worker\WorkerInterface;

class MyWorker implements WorkerInterface
{
public function process(AssetInterface $asset)
{
// ... change $asset or return a new one
}

}

And then register it as a tagged service:

.. configuration-block::

.. code-block:: yaml

services:
app.custom_assetic_worker:
class: AppBundle\Assetic\CustomWorker
tags:
- { name: assetic.factory_worker }

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.custom_assetic_worker" class="AppBundle\Assetic\CustomWorker">
<tag name="assetic.factory_worker" />
</service>
</services>
</container>

.. code-block:: php

use AppBundle\Assetic\CustomWorker;

$container
->register('app.custom_assetic_worker', CustomWorker::class)
->addTag('assetic.factory_worker')
;

assetic.filter
--------------

**Purpose**: Register a filter

AsseticBundle uses this tag to register common filters. You can also use
this tag to register your own filters.

First, you need to create a filter::

use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;

class MyFilter implements FilterInterface
{
public function filterLoad(AssetInterface $asset)
{
$asset->setContent('alert("yo");' . $asset->getContent());
}

public function filterDump(AssetInterface $asset)
{
// ...
}
}

Second, define a service:

.. configuration-block::

.. code-block:: yaml

services:
app.custom_assetic_filter:
class: AppBundle\Assetic\CustomFilter
tags:
- { name: assetic.filter, alias: my_filter }

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="app.custom_assetic_filter" class="AppBundle\Assetic\CustomFilter">
<tag name="assetic.filter" alias="my_filter" />
</service>
</services>
</container>

.. code-block:: php

use AppBundle\Assetic\CustomFilter;

$container
->register('app.custom_assetic_filter', CustomFilter::class)
->addTag('assetic.filter', array('alias' => 'my_filter'))
;

Finally, apply the filter:

.. code-block:: twig

{% javascripts
'@AcmeBaseBundle/Resources/public/js/global.js'
filter='my_filter'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}

You can also apply your filter via the ``assetic.filters.my_filter.apply_to``
config option as it's described here: :doc:`/assetic/apply_to_option`.
In order to do that, you must define your filter service in a separate xml
config file and point to this file's path via the ``assetic.filters.my_filter.resource``
configuration key.

assetic.formula_loader
----------------------

**Purpose**: Add a formula loader to the current asset manager

A Formula loader is a class implementing
``Assetic\\Factory\Loader\\FormulaLoaderInterface`` interface. This class
is responsible for loading assets from a particular kind of resources (for
instance, twig template). Assetic ships loaders for PHP and Twig templates.

An ``alias`` attribute defines the name of the loader.

assetic.formula_resource
------------------------

**Purpose**: Adds a resource to the current asset manager

A resource is something formulae can be loaded from. For instance, Twig
templates are resources.

assetic.templating.php
----------------------

**Purpose**: Remove this service if PHP templating is disabled

The tagged service will be removed from the container if the
``framework.templating.engines`` config section does not contain php.

assetic.templating.twig
-----------------------

**Purpose**: Remove this service if Twig templating is disabled

The tagged service will be removed from the container if
``framework.templating.engines`` config section does not contain ``twig``.

auto_alias
----------

Expand Down