@@ -32,19 +32,33 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
3232 {
3333 $ className = u ($ data )->replace ('\\\\' , '\\' );
3434
35+ /**
36+ * Symfony AI classes require some special handling because of its monorepo structure. Example:
37+ *
38+ * input: Symfony\AI\Agent\Memory\StaticMemoryProvider
39+ * output: https://github.com/symfony/ai/blob/main/src/agent/src/Memory/StaticMemoryProvider.php
40+ */
3541 if (str_starts_with ($ className , 'Symfony \\AI \\' )) {
36- // Example:
37- // input: Symfony\AI\Agent\Memory\StaticMemoryProvider
38- // output: https://github.com/symfony/ai/blob/main/src/agent/src/Memory/StaticMemoryProvider.php
39-
4042 $ classPath = $ className ->after ('Symfony \\AI \\' );
4143 [$ monorepoSubRepository , $ classRelativePath ] = $ classPath ->split ('\\' , 2 );
4244 // because of monorepo structure, the first part of the classpath needs to be slugged
4345 // 'Agent' -> 'agent', 'AiBundle' -> 'ai-bundle', etc.
44- $ monorepoSubRepository = u ( $ monorepoSubRepository) ->snake ('- ' )->lower ();
45- $ classRelativePath = u ( $ classRelativePath) ->replace ('\\' , '/ ' );
46+ $ monorepoSubRepository = $ monorepoSubRepository ->snake ('- ' )->lower ();
47+ $ classRelativePath = $ classRelativePath ->replace ('\\' , '/ ' );
4648
4749 $ url = \sprintf ('https://github.com/symfony/ai/blob/main/src/%s/src/%s.php ' , $ monorepoSubRepository , $ classRelativePath );
50+ /**
51+ * Symfony UX classes require some special handling because of its monorepo structure. Example:
52+ *
53+ * input: Symfony\UX\Chartjs\Twig\ChartExtension
54+ * output: https://github.com/symfony/ux/blob/2.x/src/Chartjs/src/Twig/ChartExtension.php
55+ */
56+ } elseif (str_starts_with ($ className , 'Symfony \\UX \\' )) {
57+ $ classPath = $ className ->after ('Symfony \\UX \\' );
58+ [$ monorepoSubRepository , $ classRelativePath ] = $ classPath ->split ('\\' , 2 );
59+ $ classRelativePath = $ classRelativePath ->replace ('\\' , '/ ' );
60+
61+ $ url = \sprintf ('https://github.com/symfony/ux/blob/2.x/src/%s/src/%s.php ' , $ monorepoSubRepository , $ classRelativePath );
4862 } else {
4963 $ url = sprintf ('%s/%s.php ' , $ this ->symfonyRepositoryUrl , $ className ->replace ('\\' , '/ ' ));
5064 }
0 commit comments