Skip to content
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

[make:twig-component] Improve make:twig-component by reading the configuration file #1571

Merged
merged 14 commits into from
Jun 18, 2024

Conversation

shadowc
Copy link
Contributor

@shadowc shadowc commented Jun 14, 2024

Small change in the way make:twig-component works when determining the namespace of the class to create.

In before, the namespace was hard coded. This is still good, but in cases where your Twig Component class namespace may have changed (i.e. your website is divided into src/Admin and src/Site and you've modified your twig_component.yaml so that your TwigComponents live under src/Site/Twig/Components), the component class would be still created under src/Twig/Components.

I've improved the command to read this config and automatically create the component under the first entry in this file. If no config is found, then we can use the old default.

TODOS:

  • Can a test be made with a special config file?

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

Awesome Work! We do need a test case for this. we can probably just copy & paste this one ->

yield 'it_generates_twig_component' => [$this->createMakerTest()

For the custom configuration file needed in the test ("fixture"), we would create that in maker-bundle/tests/fixtures/make-twig-components/custom_twig_component.yaml

Then in our test case, point to it using the $runner->copy() command. Similar to what we do here

So it would look something like:

$runner->copy(
    'make-twig-component/tests/custom_twig_component.yaml',    // path to fixture (omit the tests/fixture prefix)
    'config/packages/twig_compont.yaml`.  // destination relative to the "test app's root"
); 

If any changes need to be made to the existing tests in the fixtures/make-twig-components to run in our new test, just copy the existing fixture file -> rename it to say "GeneratedComponentTwigTest_customNamespace.php" and modify the $runner->copy() appropriately`..

Hope this helps, if ya get stuck, slack or on here :)

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels Jun 15, 2024
@jrushlow jrushlow changed the title [twig-component] Improve twig-component by reading configuration file [make:twig-component] Improve twig-component by reading configuration file Jun 15, 2024
@jrushlow jrushlow added this to the v1.61.0 milestone Jun 15, 2024
@shadowc shadowc changed the title [make:twig-component] Improve twig-component by reading configuration file [make:twig-component] Improve make:twig-component by reading the configuration file Jun 15, 2024
@shadowc
Copy link
Contributor Author

shadowc commented Jun 15, 2024

@jrushlow Hey, I created the test as you told me, but it's failing to load the config file! Let me know if I'm doing something wrong!

@shadowc shadowc requested a review from jrushlow June 15, 2024 14:33
Co-authored-by: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com>
@shadowc
Copy link
Contributor Author

shadowc commented Jun 17, 2024

I think this didn't work either...

@shadowc shadowc requested a review from jrushlow June 17, 2024 20:36
@shadowc
Copy link
Contributor Author

shadowc commented Jun 18, 2024

Ok, heads up: Thanks for all the help!! Looks like tests are passing and I've made the last changes of what as discussed! I think this is ready to go!

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

Awesome work @shadowc! Thank you!

@jrushlow jrushlow added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Work Additional work is needed labels Jun 18, 2024
@jrushlow jrushlow merged commit 08b21c3 into symfony:main Jun 18, 2024
8 checks passed
@jrushlow jrushlow mentioned this pull request Aug 29, 2024
@DaveData
Copy link

This breaks if config is in php files.

Maybe go with default if yaml file can't be read? Do we even need to open/parse the yaml file to get access to the value?

@shadowc
Copy link
Contributor Author

shadowc commented Oct 28, 2024

@jrushlow hey! Let me know if I can fix this somehow? It seems we should be able to read php configs AND also default to the default value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants