Minor issue with `drush generate service:custom`
ultimike opened this issue · comments
Describe the bug
A new custom service is placed in the parameters
section of an existing module_name.services.yml file if the parameters
section is placed after the services
section.
To Reproduce
- Create a custom service using
drush generate service:custom
- Manually add a
parameters
section the new module_name.services.yml below theservices
section. - Create a second custom service using
drush generate service:custom
Expected behavior
The second service should be added to the services
section of module_name.services.yml
Actual behavior
The second service is added to the parameters
section of module_name.services.yml
Workaround
Either:
- Be sure to manually add the
parameters
section above theservices
section of module_name.services.yml - Manually move the definition of the second service created to the
services
section.
Note: I originally filed this issue here: drush-ops/drush#5267
I dont think this is fixable because the generator doesnt load the file and parse it for meaning. It just appends. This is a known and accepted limitation AFAIK.
That's true.
It's seems natural to use Yaml::decode
and Yaml::encode
to merge content but in that case we won't be able to preserve the comments and formatting of yaml files.
Be sure to manually add the parameters section above the services section of module_name.services.yml
Drupal core follows that style. Parameters section always goes first.
Roger that - makes sense. Thanks. Closing.
-mike