2009年8月21日星期五

RE: [fw-mvc] [fw-general] call a custom action helper in a model file

Hello Jorean,

 

Thanks for your reply.

Let me explain you my case. Hope it helps.

 

I have made a custom Helper file that is used by many controller files in a modular ZF application. So I have placed it in a folder at the root level, so that it can be accessed wherever necessary.

 

There is a huge functionality in the helper file, which is, of course,  used by controllers. Now there is a case wherein I want to use this functionality from inside one of my model class file. I can put this chunk of code in a file placed inside the library folder and include it later in my model file. But this will result in duplicate code and unnecessary overheads.

 

So I was thinking whether we can call this inside a model file.

Please let me know if anything else is needed from my side.

 

Thanks,

Vibhor

 

From: Jeroen Keppens [mailto:jeroen.keppens@gmail.com]
Sent: Friday, August 21, 2009 5:25 PM
To: Zend Framework MVC; fw-general@lists.zend.com
Subject: Re: [fw-mvc] [fw-general] call a custom action helper in a model file

 

Hi Vibhor,

 

I don't think it's good MVC to call action helpers (part of the controller) directly from your model.

 

I would write the functionality (can you explain a bit what you want to do), in separate classes in your library and wrap the action helper around it for use in the controller. From the model you can the use the library classes directly.

 

Can you explain a bit what you want to do?

 

Jeroen

 

 

On 21 Aug 2009, at 09:43, Vibhor Singh wrote:



Hi all,

 

Is there any way to call a custom action  helper in a model file? Can anyone suggest a different approach? Any help would be greatly appreciated.

 

Thanks,

Vibhor

 

没有评论: