-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Conversation
…e twig_component.yaml configuration file to get the proper class path
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.
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
$runner->copy( |
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 :)
make:twig-component
by reading the configuration file
@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! |
Co-authored-by: Jesse Rushlow <40327885+jrushlow@users.noreply.github.com>
I think this didn't work either... |
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! |
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.
Awesome work @shadowc! Thank you!
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? |
@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. |
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
andsrc/Site
and you've modified yourtwig_component.yaml
so that your TwigComponents live undersrc/Site/Twig/Components
), the component class would be still created undersrc/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: