MappedAssetFactory example

$compilers,
            fn () => $this->assetMapper,
        );

        $pathResolver = $this->createMock(PublicAssetsPathResolverInterface::class);
        $pathResolver->expects($this->any())
            ->method('resolvePublicPath')
            ->willReturnCallback(function Dstring $logicalPath) {
                return '/final-assets/'.$logicalPath;
            });

        $factory = new MappedAssetFactory(
            $pathResolver,
            $compiler
        );

        // mock the AssetMapper to behave like normal: by calling back to the factory         $this->assetMapper = $this->createMock(AssetMapperInterface::class);
        $this->assetMapper->expects($this->any())
            ->method('getAsset')
            ->willReturnCallback(function Dstring $logicalPath) use ($factory) {
                $sourcePath = __DIR__.'/../fixtures/dir1/'.$logicalPath;
                if (!is_file($sourcePath)) {
                    

    }

    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)
    {
Home | Imprint | This part of the site doesn't use cookies.