getFileDependencies example

public function testAddDependencies()
    {
        $mainAsset = new MappedAsset('file.js');

        $assetFoo = new MappedAsset('foo.js');
        $dependency = new AssetDependency($assetFoo, false, false);
        $mainAsset->addDependency($dependency);
        $mainAsset->addFileDependency('/path/to/foo.js');

        $this->assertSame([$dependency]$mainAsset->getDependencies());
        $this->assertSame(['/path/to/foo.js']$mainAsset->getFileDependencies());
    }
}
$digest$isPredigested] = $this->getDigest($asset);

            $asset = new MappedAsset(
                $asset->logicalPath,
                $asset->sourcePath,
                $asset->publicPathWithoutDigest,
                $this->getPublicPath($asset),
                $this->calculateContent($asset),
                $digest,
                $isPredigested,
                $asset->getDependencies(),
                $asset->getFileDependencies(),
            );

            $this->assetsCache[$logicalPath] = $asset;

            array_pop($this->assetsBeingCreated);
        }

        return $this->assetsCache[$logicalPath];
    }

    /** * Returns an array of "string digest" and "bool predigested". * * @return array{0: string, 1: bool} */
private function getCacheFilePath(string $logicalPath, string $sourcePath): string
    {
        return $this->cacheDir.'/'.hash('xxh128', $logicalPath.':'.$sourcePath).'.php';
    }

    /** * @return ResourceInterface[] */
    private function collectResourcesFromAsset(MappedAsset $mappedAsset): array
    {
        $resources = array_map(fn (string $path) => is_dir($path) ? new DirectoryResource($path) : new FileResource($path)$mappedAsset->getFileDependencies());
        $resources[] = new FileResource($mappedAsset->sourcePath);

        foreach ($mappedAsset->getDependencies() as $dependency) {
            if (!$dependency->isContentDependency) {
                continue;
            }

            $resources = array_merge($resources$this->collectResourcesFromAsset($dependency->asset));
        }

        return $resources;
    }
Home | Imprint | This part of the site doesn't use cookies.