Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 22, 2023

Fix #1455

{
$text = str_replace('\\', '/', $file);
if (str_starts_with($text, $this->projectDir)) {
$text = mb_substr($text, \mb_strlen($this->projectDir));
Copy link
Member

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)

Copy link
Member Author

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.

<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>
Copy link
Member

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 ?

Copy link
Member Author

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.

namespace App\Twig;

use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\ErrorHandler\ErrorRenderer\FileLinkFormatter;
Copy link
Member Author

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.

Copy link
Member

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.

@javiereguiluz
Copy link
Member

Jérôme, thanks for taking care of this in preparation for the upstream changes in Symfony.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't use Twig CodeExtension helpers outside of a profiler panel

3 participants