Skip to content

Commit f445745

Browse files
committed
More precisely initializing services/config for asset mapper
1 parent 22dafa0 commit f445745

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/DependencyInjection/SwupExtension.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function load(array $configs, ContainerBuilder $container)
2727

2828
public function prepend(ContainerBuilder $container)
2929
{
30-
if (!interface_exists(AssetMapperInterface::class)) {
30+
if (!$this->isAssetMapperAvailable($container)) {
3131
return;
3232
}
3333

@@ -39,4 +39,19 @@ public function prepend(ContainerBuilder $container)
3939
],
4040
]);
4141
}
42+
43+
private function isAssetMapperAvailable(ContainerBuilder $container): bool
44+
{
45+
if (!interface_exists(AssetMapperInterface::class)) {
46+
return false;
47+
}
48+
49+
// check that FrameworkBundle 6.3 or higher is installed
50+
$bundlesMetadata = $container->getParameter('kernel.bundles_metadata');
51+
if (!isset($bundlesMetadata['FrameworkBundle'])) {
52+
return false;
53+
}
54+
55+
return is_file($bundlesMetadata['FrameworkBundle']['path'].'/Resources/config/asset_mapper.php');
56+
}
4257
}

0 commit comments

Comments
 (0)