---
title: "Service Interfaces"
manual: "Vite AssetCollector"
version: "main"
permalink: "https://docs.typo3.org/permalink/praetorius/vite-asset-collector:extending-interfaces@main"
source: "Extending/Interfaces.rst"
rendered: "2026-11-15T13:51:42+00:00"
---

# Service Interfaces {#extending-interfaces}

The extension's main services are defined by interfaces. All other parts
of the extension, including the ViewHelpers, depend on these interfaces
instead of the concrete implementations. This allows changing the core
functionality of the extension by providing a different implementation
of an interface.

## AssetRendererInterface {#extending-interfaces-asset-renderer}

Asset renderers are responsible for embedding Vite entrypoints, either
in dev server or in build context.

`PraetoriusViteAssetCollectorAssetAssetRendererInterface`

## AssetUriGeneratorInterface {#extending-interfaces-asset-uri-generator}

Asset URI generators are responsible for generating URIs to asset files
covered by Vite, both in dev server and in build context.

`PraetoriusViteAssetCollectorAssetAssetUriGeneratorInterface`

## AssetPathResolverInterface {#extending-interfaces-asset-path-resolver}

Asset path resolvers are responsible for resolving provided path strings
(e. g. with `EXT:` prefix) to actual file paths.

`PraetoriusViteAssetCollectorAssetAssetPathResolverInterface`

## Replacing or decorating a service {#extending-interfaces-replace}

To replace an implementation, alias the interface to your own class:

**EXT:sitepackage/Configuration/Services.yaml**

```yaml
services:
    Praetorius\ViteAssetCollector\Asset\AssetRendererInterface:
        alias: MyVendor\Sitepackage\Vite\CustomAssetRenderer
```

To only adjust parts of the default behavior, decorate the service instead:

**EXT:sitepackage/Classes/Vite/CustomAssetRenderer.php**

```php
namespace MyVendor\Sitepackage\Vite;

use Praetorius\ViteAssetCollector\Asset\Asset;
use Praetorius\ViteAssetCollector\Asset\AssetRendererInterface;
use Praetorius\ViteAssetCollector\Asset\Manifest\Manifest;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;

#[AsDecorator(AssetRendererInterface::class)]
final readonly class CustomAssetRenderer implements AssetRendererInterface
{
    public function __construct(
        #[AutowireDecorated]
        private AssetRendererInterface $inner,
    ) {}

    public function renderDevAsset(Asset $asset, UriInterface $devServerUri, ServerRequestInterface $request): void
    {
        $this->inner->renderDevAsset($asset, $devServerUri, $request);
    }

    public function renderBuildAsset(Asset $asset, Manifest $manifest, ServerRequestInterface $request): void
    {
        // ...
        $this->inner->renderBuildAsset($asset, $manifest, $request);
    }
}
```

Note that your extension must declare `vite_asset_collector` as
a dependency for this to work correctly.
