Skip to content

Commit

Permalink
Merge pull request #2347 from Haehnchen/feature/asset-mapper-asset
Browse files Browse the repository at this point in the history
add support for assets of AssetMapper
  • Loading branch information
Haehnchen committed Apr 7, 2024
2 parents b358ff0 + 94686c7 commit a12ead4
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ private static Collection<VirtualFile> getProjectAssetRoot(@NotNull Project proj
paths.add("public"); // latest Symfony structure
paths.add("web"); // old Symfony structure

// find asset mapper files
for (VirtualFile file : FilenameIndex.getVirtualFilesByName("installed.php", GlobalSearchScope.allScope(project))) {
// composer
VirtualFile parent = file.getParent();
if (parent == null || !"vendor".equals(parent.getName())) {
continue;
}

VirtualFile assetFolder = parent.getParent();
if (assetFolder == null) {
continue;
}

String relativePath = VfsUtil.getRelativePath(assetFolder, ProjectUtil.getProjectDir(project), '/');
if (relativePath != null) {
paths.add(relativePath);
}
}

return paths.stream()
.map(path -> VfsUtil.findRelativeFile(ProjectUtil.getProjectDir(project), path.split("/")))
.filter(Objects::nonNull)
Expand Down

0 comments on commit a12ead4

Please sign in to comment.