-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Use the router to resolve the file links in the profiler #24153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,14 @@ class FileLinkFormatter implements \Serializable | |
{ | ||
private $fileLinkFormat; | ||
private $requestStack; | ||
private $router; | ||
private $urlGenerator; | ||
private $baseDir; | ||
private $queryString; | ||
|
||
public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $queryString = null, UrlGeneratorInterface $router = null) | ||
/** | ||
* @param $urlGenerator UrlGeneratorInterface | ||
*/ | ||
public function __construct($fileLinkFormat = null, $urlGenerator = null, $baseDir = null, $queryString = null) | ||
{ | ||
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | ||
if ($fileLinkFormat && !is_array($fileLinkFormat)) { | ||
|
@@ -36,10 +39,17 @@ public function __construct($fileLinkFormat = null, RequestStack $requestStack = | |
} | ||
|
||
$this->fileLinkFormat = $fileLinkFormat; | ||
$this->requestStack = $requestStack; | ||
$this->router = $router; | ||
$this->baseDir = $baseDir; | ||
$this->queryString = $queryString; | ||
|
||
if ($urlGenerator instanceof RequestStack) { | ||
@trigger_error(sprintf('Passing a RequestStack to %s() as a second argument is deprecated since version 3.4 and will be unsupported in 4.0. Pass a UrlGeneratorInterface instead.', __METHOD__), E_USER_DEPRECATED); | ||
$this->requestStack = $urlGenerator; | ||
} elseif ($urlGenerator instanceof UrlGeneratorInterface) { | ||
$this->urlGenerator = $urlGenerator; | ||
} elseif (null !== $urlGenerator) { | ||
throw new \InvalidArgumentException('The second argument of %s() must either implement UrlGeneratorInterface or RequestStack.'); | ||
} | ||
} | ||
|
||
public function format($file, $line) | ||
|
@@ -78,9 +88,9 @@ private function getFileLinkFormat() | |
return $this->fileLinkFormat; | ||
} | ||
|
||
if (null !== $this->router) { | ||
if (null !== $this->urlGenerator) { | ||
return array( | ||
$this->router->generate('_profiler_open_file').$this->queryString, | ||
$this->urlGenerator->generate('_profiler_open_file').$this->queryString, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That ties it to the definition of WebProfilerBundle. I suggest that we make it configurable instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we please do that in the future in case enough people ask for it? |
||
$this->baseDir.DIRECTORY_SEPARATOR, '', | ||
); | ||
} | ||
|
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param UrlGeneratorInterface $urlGenerator