Skip to content

fix: Preserve sub-namespace when generating Entity from Model (--return=entity)#10232

Open
xgrind wants to merge 1 commit into
codeigniter4:developfrom
xgrind:subnamespace
Open

fix: Preserve sub-namespace when generating Entity from Model (--return=entity)#10232
xgrind wants to merge 1 commit into
codeigniter4:developfrom
xgrind:subnamespace

Conversation

@xgrind
Copy link
Copy Markdown

@xgrind xgrind commented May 22, 2026

This change ensures that when a model is generated with --return=entity,
the Entity generator is invoked with the fully-qualified entity class name
so any sub-namespace in the model name (for example Admin) is preserved
in the Entity file and namespace.

How to reproduce (before fix)

  1. Run: php spark make:model Admin/Class --return entity
  2. Model is created under app/Models/Admin/Class.php
  3. Entity is created under app/Entities/Class.php (missing Admin namespace)

How to verify (after applying fix)

  1. Run: php spark make:model Admin/Class --return entity
  2. Model: app/Models/Admin/Class.php
  3. Entity: app/Entities/Admin/Class.php (namespace App\Entities\Admin)

@mergeable
Copy link
Copy Markdown

mergeable Bot commented May 22, 2026

Hi there, xgrind! 👋

Thank you for sending this PR!

We expect the following in all Pull Requests (PRs).

Important

We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works.

If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work
on the framework than you do. Please make it as painless for your contributions to be included as possible.

See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md

Sincerely, the mergeable bot 🤖

@xgrind xgrind changed the title Preserve sub-namespace when generating Entity from Model (--return=entity) fix: Preserve sub-namespace when generating Entity from Model (--return=entity) May 22, 2026
@xgrind xgrind closed this May 22, 2026
@xgrind xgrind deleted the subnamespace branch May 22, 2026 19:06
@xgrind xgrind restored the subnamespace branch May 22, 2026 19:08
@xgrind xgrind reopened this May 22, 2026
@paulbalandan
Copy link
Copy Markdown
Member

Please add a test showing the fix works.

@paulbalandan paulbalandan added the tests needed Pull requests that need tests label May 23, 2026
@xgrind
Copy link
Copy Markdown
Author

xgrind commented May 23, 2026

// before the fix
[michael@desktop CodeIgniter4 (develop)]$ php spark make:model admin/class --return entity

CodeIgniter v4.7.3-dev Command Line Tool - Server Time: 2026-05-23 14:24:35 UTC+00:00

File created: APPPATH/Entities/Class.php

File created: APPPATH/Models/Admin/Class.php


// after the fix
[michael@desktop CodeIgniter4 (develop)]$ php spark make:model admin/class --return entity

CodeIgniter v4.7.3-dev Command Line Tool - Server Time: 2026-05-23 14:27:11 UTC+00:00

File created: APPPATH/Entities/Admin/Class.php

File created: APPPATH/Models/Admin/Class.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests needed Pull requests that need tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants