0

I am working on migrating an application to an framework application (specifically Fusebox 5.5). I would need to extend two Application.cfc [Fusebox5.Application] and another Application.cfc that sits in a folder a couple directories up. Below is the directory structure:

--WebRoot 
    --Fusebox5 <---(This is where the corefiles for Fusebox is stored)
    --Folder1 <---(This is the Application.CFC file I want to extend)
        --sub-Folder1
            --sub-subOfFolder1
                --sub-sub-subOfFolder1
                    --Application Folder (This is where the application lives)

The Application.cfc file has the following code:

<cfcomponent extends="fusebox5.Application" output="false">

It's not as simple as adding fusebox5.Application,Folder1.Application, but basically, is what I want to do. Any help would be appreciated.

Couple caveats:

  • I do NOT want to make any impact on any existing code outside of the Application folder. I read about extending an ApplicationProxy.cfc and would probably be willing to try that out, but that would be the extent of any modifications to existing code base.
  • I can consider an alternative framework, but a lot of the existing code base that I'm migrating would not lend itself very well. My primary objective would simply to be organize code.
Chester
  • 1,081
  • 9
  • 18
  • 1
    It doesn't make a great deal of sense to want to extend two different Application.cfc's in a multiple inheritance sort of way. Well not to me anyhow. Why is it you need to extend both the application's and Fusebox's Application.cfcs? I don't doubt you need to do it for some reason, but elaborating upon the reason would help answering. – Adam Cameron Jul 01 '13 at 21:26
  • Jesus I don't believe I put an apostrophe in "Application.cfc's" :-/ – Adam Cameron Jul 01 '13 at 21:46
  • @AdamCameron - I was attempting to do this to utilize both Fusebox's Application.CFC, which is needed for the framework to run, as well as the original application's Application.cfc. I do not know what the extent it is being utilized, but I know at least the application name, DSN, and some onRequestStart settings are initialized there. I agree with you that it doesn't really make sense. I've sort of scrapped the idea of putting it in a structured framework and am now just attempting to reorganize / decouple the pages. – Chester Jul 01 '13 at 22:15

1 Answers1

1

Without knowing which bits from which Application.cfc you need to re-use, it's difficult to answer this.

However you cannot have multiple inheritance in CF. I guess you know this.

You could conceivably create a new CFC in your sub app which extends the one in the main app, and then create an instance of that wihthn your sup-app's Application.cfc. You can then call its public methods and access its THIS scope as needs must.

And your sub-app can then extend the Fusebox one as per normal.

Or, possibly, do it the other way around, depending on which makes more sense.

Other than that, you could refactor the bits you need from the main app into some other construct (and include file, a different CFC or something), and then call that code from each of the main-app and sub-app, and again extend Fusebox from the sub-app. Obviously this means monkeying with the main app, and regression testing again, etc.

Adam Cameron
  • 29,677
  • 4
  • 37
  • 78
  • Adam, thanks for the insight. I'll look into creating the new CFC for the sub-app and extending from there. I have a feeling I'm going to run into some conflicts (onRequestStart, I think). Though I am reluctant to do it, and probably won't, what are your thoughts on adding stuff from the App.CFC to the Fusebox.CFC? – Chester Jul 02 '13 at 16:01
  • I wouldn't mess with the Fusebox Application.cfc, no. The Application.cfc in there should only concern itself with FB things; just like, really, the Application.cfc files in the other apps should *really* only concern themselves with their own interests. I guess your situation is "interesting" because it's entirely possible to have an app that "is a" Fusebox app ("is a" being used in the OO sense, as well as "is a " [your sub app]. But the sub app fails the "is a" fusebox app. – Adam Cameron Jul 02 '13 at 16:53
  • Other frameworks (like ColdBox) can be run either using the "extends" model like you are trying with Fusebox here, or in a "embedded instance" model, where the Coldbox all stuff is just an instance variable of your Application.cfc, and you call methods on it rather than relying on it being extended by your app. Can Fusebox not be run this way? – Adam Cameron Jul 02 '13 at 16:55