Skip to content
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

Nested mapping #343

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Nested mapping #343

wants to merge 2 commits into from

Conversation

jhabaj
Copy link

@jhabaj jhabaj commented Jan 10, 2025

  • new feature
  • BC break? no - generally fully backward compatible, though some applications may have specific edge cases
  • doc PR: nette/docs#???

This pull request introduces an enhancement to the presenter mapping functionality, allowing support for mappings within multiple namespaces.

Currently, adding a new app module requires specifying mappings like this:

'ForumModule' => 'Other\*Mod\*Presenter';
Applications such as CMS systems must carefully manage link generation between frontend and admin modules, ensuring routes are correct for each.

Proposed Solution:
The proposal enables nested mapping, simplifying the creation of links using only the module name and presenter. It eliminates the need to create separate routes for each module.

'Admin' => 'App\*Mod\*Presenter',
'Admin:ForumModule' => 'Other\*Mod\*Presenter',
'Admin:Module:ForumModule' => 'Other\*Mod\*Presenter', // Length is customizable based on application needs

Benefits

  • Improved Modularity: Each module can function as an independent composer package, extending shared presenters and integrating seamlessly into the application.
  • Streamlined Link Generation: Linking becomes more intuitive, relying on the module name and presenter alone.
  • Plugin System Potential: Applications can adopt a plugin-like structure, where modules extend common functionality and are easily reusable.
  • This change aims to make Nette applications more flexible and modular, reducing the overhead of managing complex routing setups while supporting scalable, pluggable architectures.

@jhabaj jhabaj marked this pull request as ready for review January 10, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant