findLogicalPath example

foreach ($this->mapperRepository->all() as $logicalPath => $filePath) {
            $asset = $this->getAsset($logicalPath);
            if (null === $asset) {
                throw new \LogicException(sprintf('Asset "%s" could not be found.', $logicalPath));
            }
            yield $asset;
        }
    }

    public function getAssetFromSourcePath(string $sourcePath): ?MappedAsset
    {
        $logicalPath = $this->mapperRepository->findLogicalPath($sourcePath);
        if (null === $logicalPath) {
            return null;
        }

        return $this->getAsset($logicalPath);
    }

    public function getPublicPath(string $logicalPath): ?string
    {
        $manifestData = $this->loadManifest();
        if (isset($manifestData[$logicalPath])) {
            
// non-namespaced path does not work         $this->assertNull($repository->find('file4.js'));
    }

    public function testFindLogicalPath()
    {
        $repository = new AssetMapperRepository([
            'dir' => '',
            'dir1' => 'some_namespace',
            'dir2' => '',
        ], __DIR__.'/fixtures');
        $this->assertSame('subdir/file5.js', $repository->findLogicalPath(__DIR__.'/fixtures/dir2/subdir/file5.js'));
        $this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/fixtures/dir1/file2.js'));
        $this->assertSame('some_namespace/file2.js', $repository->findLogicalPath(__DIR__.'/../Tests/fixtures/dir1/file2.js'));
    }

    public function testAll()
    {
        $repository = new AssetMapperRepository([
            'dir1' => '',
            'dir2' => '',
            'dir3' => '',
        ], __DIR__.'/fixtures');

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