@@ -32,10 +32,27 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
3232 {
3333 $ className = u ($ data )->replace ('\\\\' , '\\' );
3434
35+ 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+
40+ $ classPath = $ className ->after ('Symfony \\AI \\' );
41+ [$ monorepoSubRepository , $ classRelativePath ] = $ classPath ->split ('\\' , 2 );
42+ // because of monorepo structure, the first part of the classpath needs to be slugged
43+ // 'Agent' -> 'agent', 'AiBundle' -> 'ai-bundle', etc.
44+ $ monorepoSubRepository = u ($ monorepoSubRepository )->snake ('- ' )->lower ();
45+ $ classRelativePath = u ($ classRelativePath )->replace ('\\' , '/ ' );
46+
47+ $ url = \sprintf ('https://github.com/symfony/ai/blob/main/src/%s/src/%s.php ' , $ monorepoSubRepository , $ classRelativePath );
48+ } else {
49+ $ url = sprintf ('%s/%s.php ' , $ this ->symfonyRepositoryUrl , $ className ->replace ('\\' , '/ ' ));
50+ }
51+
3552 return new ResolvedReference (
3653 $ environment ->getCurrentFileName (),
3754 $ className ->afterLast ('\\' ),
38- sprintf ( ' %s/%s.php ' , $ this -> symfonyRepositoryUrl , $ className -> replace ( '\\' , ' / ' )) ,
55+ $ url ,
3956 [],
4057 [
4158 'title ' => $ className ,
0 commit comments