AssetMapper example

private function createAssetMapper(): AssetMapper
    {
        $dirs = ['dir1' => '', 'dir2' => '', 'dir3' => ''];
        $repository = new AssetMapperRepository($dirs, __DIR__.'/fixtures');
        $pathResolver = $this->createMock(PublicAssetsPathResolverInterface::class);
        $pathResolver->expects($this->any())
            ->method('getPublicFilesystemPath')
            ->willReturn(__DIR__.'/fixtures/test_public/final-assets');

        $this->mappedAssetFactory = $this->createMock(MappedAssetFactoryInterface::class);

        return new AssetMapper(
            $repository,
            $this->mappedAssetFactory,
            $pathResolver,
        );
    }
}
private function createAssetMapper(PublicAssetsPathResolverInterface $pathResolver, array $dirs, string $rootDir): AssetMapper
    {
        $repository = new AssetMapperRepository($dirs$rootDir);

        $compiler = new AssetMapperCompiler(
            [new JavaScriptImportPathCompiler()],
            fn () => $this->assetMapper
        );
        $factory = new MappedAssetFactory($pathResolver$compiler);

        $this->assetMapper = new AssetMapper(
            $repository,
            $factory,
            $pathResolver
        );

        return $this->assetMapper;
    }

    private static function resolvedPackage(string $packageName, string $url, bool $download = false, bool $preload = false, string $importName = null, string $content = null)
    {
        return new ResolvedImportMapPackage(
            
Home | Imprint | This part of the site doesn't use cookies.