Moving an existing app to an extension

Hello,

I have an existing application that I’m converting to a Radiant
extension and I was wondering what the best thing to do is with respect
to code I have in my existing applications ApplicationController and
ApplicationHelper? I can’t redefine the ApplicationController, but I’d
like to take some of the code I have in it and “extend” Radiant’s
ApplicationController with my own custom code since all of my
application controllers already derive from ApplicationController.

Any recommendations on the approach to take?

Thanks,
Andrew

Andrew K. wrote:

Hello,

I have an existing application that I’m converting to a Radiant
extension and I was wondering what the best thing to do is with respect
to code I have in my existing applications ApplicationController and
ApplicationHelper? I can’t redefine the ApplicationController, but I’d
like to take some of the code I have in it and “extend” Radiant’s
ApplicationController with my own custom code since all of my
application controllers already derive from ApplicationController.

Any recommendations on the approach to take?

Thanks,
Andrew

I’m thinking that perhaps creating a new base class for a controller is
the cleanest approach.

So
class MyNewBaseController < ApplicationController
end

And all my existing controller derive from MyNewBaseController.

It means I have to update all of my controllers now, but is this how I
should do it?

Create a controller in your extension and have it inherit from
ApplicationController. Put all of the code that you want to keep from
ApplicationController and put it in there. Then, change all of your
controllers to inherit from this controller, rather than from
ApplicationController.

This will let all of your controllers inherit these methods you want
to share, without polluting Radiant’s ApplicationController class.

Jamey

Jamey C. wrote:

Create a controller in your extension and have it inherit from
ApplicationController. Put all of the code that you want to keep from
ApplicationController and put it in there. Then, change all of your
controllers to inherit from this controller, rather than from
ApplicationController.

This will let all of your controllers inherit these methods you want
to share, without polluting Radiant’s ApplicationController class.

Jamey

Looks like I beat ya to my own solution… thanks for reaffirming what I
was thinking!