From f4dbec46fff2b37f062d0221bf05efd36e20b015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20TAMARELLE?= Date: Thu, 1 Oct 2020 01:28:00 +0200 Subject: [PATCH] [Framework] Add tag assets.package --- reference/dic_tags.rst | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 0aca3c91777..2e4c7e5b339 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -12,6 +12,7 @@ application there could be more tags available provided by third-party bundles: Tag Name Usage ======================================== ======================================================================== `auto_alias`_ Define aliases based on the value of container parameters +`assets.package`_ Add an asset package `console.command`_ Add a command `container.hot_path`_ Add to list of always needed services `container.no_preload`_ Remove a class from the list of classes preloaded by PHP @@ -50,6 +51,57 @@ Tag Name Usage `validator.initializer`_ Register a service that initializes objects before validation ======================================== ======================================================================== +assets.package +-------------- + +**Purpose**: Add an asset package to the application + +This is an alternative way to declare a package in :doc:`/components/asset`. + +The name of the package is set in this order: +* first, the `package` attribute of the tag +* then, the value returned by the static method `getDefaultPackageName()` if defined +* finally, the service name + +.. configuration-block:: + + .. code-block:: yaml + + services: + App\Assets\AvatarPackage: + tags: + - { name: assets.package, package: avatars } + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + use App\Assets\AvatarPackage; + + $container + ->register(AvatarPackage::class) + ->addTag('assets.package', ['package' => 'avatars']) + ; + +Now you can use the ``avatars`` package in your templates: + +.. code-block:: html+twig + + + auto_alias ----------