getCurrentModule at handler.init() or as property

Hi,

is there a possibility to get the modules name/entryPoint at handler initialization?
Or are there any plans to make ModuleSettings available via autowire DSL:
something like ... coldbox:modSetting:{entryPoint}:{setting}?

Regards, Daniel

lists@platform.ch

Hi Daniel - Would this work for what you need?

  property name="entryPoint";

  function init(controller) {

    entryPoint = controller.getSetting("modules")
[controller.getRequestService().getContext().getCurrentModule()].entryPoint;

  }

I'm not sure about doing it via autowire, maybe someone else can
answer that.

read the API, you have a method called getModuleSettings() available

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks Luis.

So a more concise version is:

        property name="entryPoint";

        function init(controller) {

                entryPoint = getModuleSettings
( controller.getRequestService().getContext().getCurrentModule() ).entryPoint;

        }

getCurrentModule() is not part of the framework supertype so I am not
sure if there is a better way to get at the current module name. It's
probably in the docs somewhere :slight_smile:

bret, this constructor is for what?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

it's a handler. I was coming up with something for Daniel's initial
question.

Hi Brett and Luis

thanks a lot for your advise.

The first hint works well:
variables.entryPoint = controller.getSetting("modules")[controller.getRequestService().getContext().getCurrentModule()].entryPoint;

Second gives me an error
variables['entryPoint'] = controller.getModuleSettings(controller.getRequestService().getContext().getCurrentModule()).entryPoint;

Error
component [coldbox.system.web.Controller] has no function with name [GETMODULESETTINGS].

My goal is to use entryPoint as unique identifier regarding further model-related code.
For this, i do associate the modules folder name to entryPoint in ModuleConfig.cfc:

variables.moduleDirectory = GetDirectoryFromPath(getCurrentTemplatePath());
variables.moduleDirectory = Replace(variables.moduleDirectory, '\','/','all');
variables.moduleDirectory = ListLast(variables.moduleDirectory,'/');
this.entryPoint = variables.moduleDirectory;

After that, i would like to forward that identifier to my modules handlers and domain-model.
I am using auto-wireing without Coldspring/Lightwire.

This way i am trying to simplify my modules following more "Convention over Configuration".

Daniel

lists@platform.ch