Custom module namespace and routing

jrslv
Member | 2
+
0
-

Hey guys,

I have a Nette application as part of a bigger system and because I don't really want to make unnecessary mess, I'd like to add Nette modules under specific namespaces, not just e.g. FrontModule.

Let's say there's an Api module. Ideally, I'd have Company\Project\Api with Company\Project\Api\SomePresenter etc.

The issue is that it's not really clear how to make this happen with Nette Application and Nette Route. Could you please show me the correct path? I tried some hacks like sorta namespacing the module string in route metadata (not allowed characters). I ended up reading through the Route and Application class sources, that didn't give me a lead really. Maybe there's some configuration option I'm not aware of? This might be helpful addition to the documentation as well.

Thanks and cheers to Nette!

J

David Matějka
Moderator | 5877
+
0
-

There is mapping setting in neon (since 2.1). Try this:

nette:
    application:
        mapping:
            Api: Company\Project\Api\*Presenter

Or you can write your own PresenterFactory

Last edited by matej21 (2014-06-18 23:11)

Comments

jrslv:

This is exactly what I was looking for! Thanks mate.

Now I was able to find the list of configuration options in here: https://doc.nette.org/…/configuring

(Unfortunatelly I was googling for ‘namespace’, which cannot be found on that page)

5 years ago