addFileDependency example


        if (null !== $digest) {
            $this->digest = $digest;
        }
        if (null !== $isPredigested) {
            $this->isPredigested = $isPredigested;
        }
        foreach ($dependencies as $dependency) {
            $this->addDependency($dependency);
        }
        foreach ($fileDependencies as $fileDependency) {
            $this->addFileDependency($fileDependency);
        }
    }

    /** * @return AssetDependency[] */
    public function getDependencies(): array
    {
        return $this->dependencies;
    }

    
yield 'with_multiple_dot' => ['foo.css.map', 'map'];
        yield 'with_directory' => ['foo/bar.css', 'css'];
    }

    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());
    }
}
$dependentOnContentAsset->addDependency(new AssetDependency($deeplyNestedAsset, isContentDependency: true));
        $mappedAsset->addDependency(new AssetDependency($dependentOnContentAsset, isContentDependency: true));

        $notDependentOnContentAsset = new MappedAsset(
            'already-abcdefVWXYZ0123456789.digested.css',
            __DIR__.'/../fixtures/dir2/already-abcdefVWXYZ0123456789.digested.css',
        );
        $mappedAsset->addDependency(new AssetDependency($notDependentOnContentAsset, isContentDependency: false));

        // just adding any file as an example         $mappedAsset->addFileDependency(__DIR__.'/../fixtures/importmap.php');
        $mappedAsset->addFileDependency(__DIR__.'/../fixtures/dir3');

        $factory = $this->createMock(MappedAssetFactoryInterface::class);
        $factory->expects($this->once())
            ->method('createMappedAsset')
            ->willReturn($mappedAsset);

        $cachedFactory = new CachedMappedAssetFactory(
            $factory,
            $this->cacheDir,
            true
        );
Home | Imprint | This part of the site doesn't use cookies.