Skip to content

Conversation

squrious
Copy link
Contributor

@squrious squrious commented Jun 3, 2024

Q A
Bug fix? yes
New feature? no
Issues
License MIT

Hi!

The debug:twig-component command looks for files in the anonymous template directory, but fails if some files are actually not Twig components (like .md).

For example, with a README.md file in templates/components:

$ php bin/console debug:twig-component 
[critical] Error thrown while running command "debug:twig-component". Message: "Unknown component "README.md". And no matching anonymous component template was found."

In ComponentFactory.php line 254:
                                                                                          
  Unknown component "README.md". And no matching anonymous component template was found.  
                                                                                          

debug:twig-component [<name>]

This PR restricts the finder to *.html.twig files, so others are ignored.

@carsonbot carsonbot added Bug Bug Fix TwigComponent Status: Needs Review Needs to be reviewed labels Jun 3, 2024
@@ -0,0 +1 @@
This file should not cause issues with the debug:twig:component command.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a case in TwigComponentDebugTest that check NotAComponent is not listed ?

(like the testWithNoMatchComponent test ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

Copy link
Member

@smnandre smnandre left a comment

Choose a reason for hiding this comment

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

Thank you @squrious ! 😄

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Jun 4, 2024
@kbond kbond force-pushed the twig-component/fix-debug-command-with-non-template-files branch from d702a7b to df82b4a Compare June 6, 2024 23:10
@kbond
Copy link
Member

kbond commented Jun 6, 2024

Thank you Nicolas.

@kbond kbond merged commit 673279f into symfony:2.x Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer TwigComponent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants