Problem/Motivation
drush generate subentity scaffolds the entity class, routing, links, and optionally a bundle type and a Twig template, but it does not offer to generate a .install file. The README currently tells developers to write the update hook themselves.
Steps to reproduce
- Run
drush generate subentityand answer all prompts. - Observe that no
.installfile is generated. - When a schema change is needed later, the developer must write the
hook_update_Nboilerplate by hand.
Proposed resolution
Add a With hook_update_N? question (default: no) to the generator interview. When answered yes, generate
{machine_name}.install from a new template generator/hook_update_n.install.twig.
The asset uses appendIfExists() with a header line count so that:
- if no
.installfile exists yet, the full file is created (valid PHP with the<?phpopening tag and a@filedocblock); - if a
.installfile already exists, only the hook function skeleton is appended.
Remaining tasks
- Write the MR.
User interface changes
New With hook_update_N? prompt in the drush generate subentity interview.
API changes
None.
Data model changes
None.
Issue fork subentity-3604199
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
macsim commentedComment #5
maxpahComment #7
maxpahComment #10
maxpah