I'm thinking this is something easy I am overlooking.
In my module I am using event.buildLink() to create inter-module
links. From the forgebox module example I see the example as
event.buildlink('forgebox.install')
I want to make the "forgebox" part of the buildURL argument dynamic
because as far as I can tell the route module part ("forgebox") is
based on the route registered in the host application using
addModuleRoutes() not the name of the module.
So If I were to modify the host's Routes.cfm file and change the
pattern to use another module match all my buildLink() functions will
be broken since "forgebox" is hardcoded in buildLink().
I looked for the route pattern setting in: getSettingStructure() and
getModuleSettings( event.getCurrentModule() ) but didn't see it.
That is something that I am looking at, right this moment too.
Because it doesn't have anything, I was looking at the onLoad() to set a
setting for the module that could be used module wide.
But I am also looking at using the onLoad() to set the moduleRoute as well.
My main concern at the moment is that the onLoad() can be run twice for some
reason and I still don't know why it is.
But if there is another way to do this I am looking too, the last thing I
want to do is modify more than one location where the module route may be
used.
The entry point used in SES can be pretty much anything as you can alias it, etc. So what I am seeing is the best way to reduce that entry point in the modules so it can be transportable and easy changeable.
What i would suggest is creating a setting in the module, maybe something like this:
settings = {
entryPoint = “forgebox”
};
Then in the Routes.cfm you can use that setting register the module routes:
That does makes sense but I don't think it is ideal for what I am
looking for.
The issue with using a Module setting to define the entry point is
that the entry point is still being bound to the module, so if I
wanted to modify the entry point I would have to modify the module.
Ideally the module would be indifferent to its entry point. The host
application should assign the entry point to the module and the module
would be aware of its entry point but would not explicit set it.
A use case would be if we wanted two separate forgebox modules to run
at two different entry points. The host application should assign
each module to a separate entry points, and the Modules would know
what entry point was assigned to them so they could handle inter
module linking.
An example (2 forgebox modules running on separate entry points):
Inside the forgebox module, I can't find how to determine what the
Module Route pattern matched to create links. I had expected it to be
in the settings struct getModuleSettings( event.getCurrentModule() )
but it's not. Is that value elsewhere in the API? So I can't figure
out from within forgebox if it is running on the forgebox1 or
forgebox2 route entry point.
What I want is to find the value "/myappSlug" from within my module.
Maybe we can add a new key to the event object that is populated by
the URL slug that the host app's pattern matches when it resolves the
module. Or even a way to get a structure of the host's app's route
that matched with the name of the route that matched, the pattern, and
the value that the pattern matched.
I also noticed the method event.getRoutedStruct() returns an empty
structure from my module. Is this intended?
That doesn't return what I need. That only returns the route matched
in the Module routing, not the entry part that was matched by the
addModuleRoutes pattern.