10000 [WebProfilerBundle] use the router to resolve file links by nicolas-grekas · Pull Request #26626 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WebProfilerBundle] use the router to resolve file links #26626

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@
<argument>%debug.file_link_format%</argument>
<argument type="service" id="request_stack" on-invalid="ignore" />
<argument>%kernel.project_dir%</argument>
<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
<argument type="service">
<service class="string">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice hack!

<factory function="implode" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, and yet another nice hack!
Well done :)

<argument type="collection">
<argument type="service">
<service class="string">
<factory service="router" method="generate" />
<argument>_profiler_open_file</argument>
</service>
</argument>
<argument>?file=%%f&amp;line=%%l#line%%l</argument>
</argument>
</service>
</argument>
Copy link
Member Author
@nicolas-grekas nicolas-grekas Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this generates the following code, which is exactly what we need here:

new \Symfony\Component\HttpKernel\Debug\FileLinkFormatter(NULL, ($this->services['request_stack'] ?? $this->services['request_stack'] = new \Symfony\Component\HttpFoundation\RequestStack()), $this->targetDirs[3], \implode(array(0 => ($this->services['router'] ?? $this->getRouterService())->generate('_profiler_open_file'), 1 => '?file=%f&line=%l#line%l')));

</service>
</services>
</container>
8 changes: 6 additions & 2 deletions src/Symfony/Component/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ function (ConfigCacheInterface $cache) {
}
);

require_once $cache->getPath();
if (!class_exists($this->options['matcher_cache_class'], false)) {
require_once $cache->getPath();
}

return $this->matcher = new $this->options['matcher_cache_class']($this->context);
}
Expand Down Expand Up @@ -334,7 +336,9 @@ function (ConfigCacheInterface $cache) {
}
);

require_once $cache->getPath();
if (!class_exists($this->options['generator_cache_class'], false)) {
require_once $cache->getPath();
}

$this->generator = new $this->options['generator_cache_class']($this->context, $this->logger);
}
Expand Down
0