Skip to content

Commit 8215922

Browse files
committed
bug #2342 [TwigComponent] Fix directory separator in Debug command (clussiana, smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [TwigComponent] Fix directory separator in Debug command | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | | License | MIT Component template paths are retrieved by the `SplFileInfo` class, which returns paths containing backslashes on Windows and slashes on other operating systems. So on Windows environment, the command fails as the component `Card\Card.html.twig` is not formatted into `Card:Card` Commits ------- 41d9df0 Fix copy/paste error 3664af5 CS fix d906c6e fix: replace / by DIRECTORY_SEPARATOR
2 parents 2f1e7b8 + 41d9df0 commit 8215922

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/TwigComponent/src/Command/TwigComponentDebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ private function findAnonymousComponents(): array
182182
->name('*.html.twig')
183183
;
184184
foreach ($finderTemplates as $template) {
185-
$component = str_replace('/', ':', $template->getRelativePathname());
185+
$component = str_replace(\DIRECTORY_SEPARATOR, ':', $template->getRelativePathname());
186186
$component = substr($component, 0, -10); // remove file extension ".html.twig"
187187
$path = $template->getPath();
188188

189189
if ($template->getRelativePath()) {
190-
$path = \rtrim(\substr($template->getPath(), 0, -1 * \strlen($template->getRelativePath())), '/');
190+
$path = rtrim(substr($template->getPath(), 0, -1 * \strlen($template->getRelativePath())), \DIRECTORY_SEPARATOR);
191191
}
192192

193193
if (isset($dirs[$path]) && FilesystemLoader::MAIN_NAMESPACE !== $dirs[$path]) {

0 commit comments

Comments
 (0)