• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

My little templating snafu

Enthusiast ,
Jan 20, 2014 Jan 20, 2014

Copy link to clipboard

Copied

CF10/Win7Prox64

I have a TemplatingService object.  It has it's processTemplate() function called and is passed 1 argument, a Request object which holds information about the request.

The first thing it does is execute the controller in the Request object like so:

<cfinclude template="#arguments.Request.getController()#" />

This works perfectly, as the controller file is included and executed.  Well, I'd like that controller file to be able to call functions IN the TemplateService in order to modify things about itself, and though this is easily possible by writing:

<cfset doSomeFunction( Request = arguments.Request, data=foo ) />

Something about having to constantly self-reference the request bugs me.  I understand OOP and know that objects need to be passed, but is there ANY way you can think of where I could make the aforementioned call like:

<cfset doSomething( data=foo ) />

Which would look for a doSomething() function in the TemplateService object, but automatically send the Request object as well.  Maybe some kind of proxy object?  I've tried putting an onMissingMethod in the TemplateService, and it captures the request when I omit the function from TemplateService() but I don't have access to the Request object.  I've even tried wrapping the call to doSomething() in a cftry and then capturing the error, but even though I can then pass the Request object, I don't have access to the params that were intended to be sent to the function.

Ideas?

Views

375

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation