8000 minor #14962 [Framework] Add tag assets.package (GromNaN) · symfony/symfony-docs@6b29306 · GitHub
[go: up one dir, main page]

Skip to content
  • Insights
  • Commit 6b29306

    Browse files
    committed
    minor #14962 [Framework] Add tag assets.package (GromNaN)
    This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Framework] Add tag assets.package Documentation for symfony/symfony#38473 Commits ------- f4dbec4 [Framework] Add tag assets.package
    2 parents bfebdd4 + f4dbec4 commit 6b29306

    File tree

    1 file changed

    +52
    -0
    lines changed

    1 file changed

    +52
    -0
    lines changed

    reference/dic_tags.rst

    Lines changed: 52 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -12,6 +12,7 @@ application there could be more tags available provided by third-party bundles:
    1212
    Tag Name Usage
    1313
    ======================================== ========================================================================
    1414
    `auto_alias`_ Define aliases based on the value of container parameters
    15+
    `assets.package`_ Add an asset package
    1516
    `console.command`_ Add a command
    1617
    `container.hot_path`_ Add to list of always needed services
    1718
    `container.no_preload`_ Remove a class from the list of classes preloaded by PHP
    @@ -50,6 +51,57 @@ Tag Name Usage
    5051
    `validator.initializer`_ Register a service that initializes objects before validation
    5152
    ======================================== ========================================================================
    5253

    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+
    61+
    The name of the package is set in this order:
    62+
    * first, the `package` attribute of the tag
    63+
    * then, the value returned by the static method `getDefaultPackageName()` if defined
    64+
    * finally, the service name
    65+
    66+
    .. configuration-block::
    67+
    68+
    .. code-block:: yaml
    69+
    70+
    services:
    71+
    App\Assets\AvatarPackage:
    72+
    tags:
    73+
    - { name: assets.package, package: avatars }
    74+
    75+
    .. code-block:: xml
    76+
    77+
    <?xml version="1.0" encoding="UTF-8" ?>
    78+
    <container xmlns="http://symfony.com/schema/dic/services"
    79+
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    80+
    xsi:schemaLocation="http://symfony.com/schema/dic/services
    81+
    https://symfony.com/schema/dic/services/services-1.0.xsd">
    82+
    83+
    <services>
    84+
    <service id="App\Assets\AvatarPackage">
    85+
    <tag name="assets.package" package="avatars"/>
    86+
    </service>
    87+
    </services>
    88+
    </container>
    89+
    90+
    .. code-block:: php
    91+
    92+
    use App\Assets\AvatarPackage;
    93+
    94+
    $container
    95+
    ->register(AvatarPackage::class)
    96+
    ->addTag('assets.package', ['package' => 'avatars'])
    97+
    ;
    98+
    9 6600 9+
    Now you can use the ``avatars`` package in your templates:
    100+
    101+
    .. code-block:: html+twig
    102+
    103+
    <img src="{{ asset('...', 'avatars') }}">
    104+
    53105
    auto_alias
    54106
    ----------
    55107

    0 commit comments

    Comments
     (0)
    0