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

  1. Run drush generate subentity and answer all prompts.
  2. Observe that no .install file is generated.
  3. When a schema change is needed later, the developer must write the hook_update_N boilerplate 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 .install file exists yet, the full file is created (valid PHP with the <?php opening tag and a @file docblock);
  • if a .install file 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

Command icon 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

macsim created an issue. See original summary.

macsim’s picture

Issue summary: View changes

maxpah made their first commit to this issue’s fork.

maxpah’s picture

Status: Active » Needs review

  • maxpah committed 66c45739 on 3.0.x
    task: #3604199 Add hook_update_N template to the generator
    
maxpah’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • maxpah committed 66c45739 on 4.0.x
    task: #3604199 Add hook_update_N template to the generator
    
maxpah’s picture

Status: Fixed » Closed (fixed)