11
11
12
12
namespace Symfony \Component \HttpKernel \Debug ;
13
13
14
+ use Symfony \Component \ErrorHandler \ErrorRenderer \ErrorRendererInterface ;
14
15
use Symfony \Component \HttpFoundation \Request ;
15
16
use Symfony \Component \HttpFoundation \RequestStack ;
16
17
use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
24
25
*/
25
26
class FileLinkFormatter
26
27
{
27
- private const FORMATS = [
28
- 'textmate ' => 'txmt://open?url=file://%f&line=%l ' ,
29
- 'macvim ' => 'mvim://open?url=file://%f&line=%l ' ,
30
- 'emacs ' => 'emacs://open?url=file://%f&line=%l ' ,
31
- 'sublime ' => 'subl://open?url=file://%f&line=%l ' ,
32
- 'phpstorm ' => 'phpstorm://open?file=%f&line=%l ' ,
33
- 'atom ' => 'atom://core/open/file?filename=%f&line=%l ' ,
34
- 'vscode ' => 'vscode://file/%f:%l ' ,
35
- ];
36
-
37
28
private array |false $ fileLinkFormat ;
38
29
private ?RequestStack $ requestStack = null ;
39
30
private ?string $ baseDir = null ;
@@ -44,7 +35,8 @@ class FileLinkFormatter
44
35
*/
45
36
public function __construct (string $ fileLinkFormat = null , RequestStack $ requestStack = null , string $ baseDir = null , string |\Closure $ urlFormat = null )
46
37
{
47
- $ fileLinkFormat = (self ::FORMATS [$ fileLinkFormat ] ?? $ fileLinkFormat ) ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' ) ?: false ;
38
+ $ fileLinkFormat ??= $ _SERVER ['SYMFONY_IDE ' ] ?? null ;
39
+ $ fileLinkFormat = (ErrorRendererInterface::IDE_LINK_FORMATS [$ fileLinkFormat ] ?? $ fileLinkFormat ) ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' ) ?: false ;
48
40
if ($ fileLinkFormat && !\is_array ($ fileLinkFormat )) {
49
41
$ i = strpos ($ f = $ fileLinkFormat , '& ' , max (strrpos ($ f , '%f ' ), strrpos ($ f , '%l ' ))) ?: \strlen ($ f );
50
42
$ fileLinkFormat = [substr ($ f , 0 , $ i )] + preg_split ('/&([^>]++)>/ ' , substr ($ f , $ i ), -1 , \PREG_SPLIT_DELIM_CAPTURE );
0 commit comments