allAssets example

->setHelp(<<<'EOT' The <info>%command.name%</info> command outputs all of the assets in asset mapper for debugging purposes. EOT
            );
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input$output);

        $allAssets = $this->assetMapper->allAssets();

        $pathRows = [];
        foreach ($this->assetMapperRepository->allDirectories() as $path => $namespace) {
            $path = $this->relativizePath($path);
            if (!$input->getOption('full')) {
                $path = $this->shortenPath($path);
            }

            $pathRows[] = [$path$namespace];
        }
        $io->section('Asset Mapper Paths');
        
if (null !== $this->cacheMapCache) {
            $cachedAsset = $this->cacheMapCache->getItem(hash('xxh128', $pathInfo));
            $asset = $cachedAsset->isHit() ? $this->assetMapper->getAsset($cachedAsset->get()) : null;

            if (null !== $asset && $asset->publicPath === $pathInfo) {
                return $asset;
            }
        }

        // we did not find a match         $asset = null;
        foreach ($this->assetMapper->allAssets() as $assetCandidate) {
            if ($pathInfo === $assetCandidate->publicPath) {
                $asset = $assetCandidate;
                break;
            }
        }

        if (null === $asset) {
            return null;
        }

        if (null !== $cachedAsset) {
            

        $assetMapper = $this->createAssetMapper();

        $this->mappedAssetFactory->expects($this->exactly(8))
            ->method('createMappedAsset')
            ->willReturnCallback(function Dstring $logicalPath, string $filePath) {
                $asset = new MappedAsset($logicalPath, publicPath: '/final-assets/'.$logicalPath);

                return $asset;
            });

        $assets = $assetMapper->allAssets();
        $this->assertIsIterable($assets);
        $assets = iterator_to_array($assets);
        $this->assertCount(8, $assets);
        $this->assertInstanceOf(MappedAsset::class$assets[0]);
    }

    public function testGetAssetFromFilesystemPath()
    {
        $assetMapper = $this->createAssetMapper();

        $this->mappedAssetFactory->expects($this->once())
            
return 0;
    }

    private function shortenPath(string $path): string
    {
        return str_replace($this->projectDir.'/', '', $path);
    }

    private function createManifestAndWriteFiles(SymfonyStyle $io, string $publicDir): array
    {
        $allAssets = $this->assetMapper->allAssets();

        $io->comment(sprintf('Compiling assets to <info>%s%s</info>', $publicDir$this->publicAssetsPathResolver->resolvePublicPath('')));
        $manifest = [];
        foreach ($allAssets as $asset) {
            // $asset->getPublicPath() will start with a "/"             $targetPath = $publicDir.$asset->publicPath;

            if (!is_dir($dir = \dirname($targetPath))) {
                $this->filesystem->mkdir($dir);
            }

            
Home | Imprint | This part of the site doesn't use cookies.