-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Create link_source_file
helper to replace internal WebProfiler helper
#1456
Conversation
src/Twig/SourceCodeExtension.php
Outdated
{ | ||
$text = str_replace('\\', '/', $file); | ||
if (str_starts_with($text, $this->projectDir)) { | ||
$text = mb_substr($text, \mb_strlen($this->projectDir)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use mbstring here to remove the string from the start (we know it already starts with it): substr($text, \strlen($this->projectDir))
works just fine (and would work even if the filesystem path is not in UTF-8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, that was updated by php-cs-fixer.
@@ -30,15 +30,15 @@ | |||
<div class="tab-content" id="myTabContent"> | |||
<div class="tab-pane show active" id="controller-code" role="tabpanel" aria-labelledby="controller-tab"> | |||
{% if controller %} | |||
<p class="file-link">{{ controller.file_path|format_file(controller.starting_line) }}</p> | |||
<p class="file-link">{{ link_source_file(controller.file_path, controller.starting_line) }}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why making it a Twig function and not a filter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because both arguments are equally required. It seems more coherent to me to have them at the same level.
@@ -11,6 +11,8 @@ | |||
|
|||
namespace App\Twig; | |||
|
|||
use Symfony\Component\DependencyInjection\Attribute\Autowire; | |||
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This FileLinkFormatter
class was moved in Symfony 6.4, I'll wait for the demo project to be upgraded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Let's merge this and then we'll update the other PR that upgrades the app to 6.4. Thanks.
Jérôme, thanks for taking care of this in preparation for the upstream changes in Symfony. |
Fix #1455