Vibhor you are missing Jeroen's point.
Calling action helpers inside models would be a poor design decision.
The model should not need anything that isn't supplied to it by the
code calling it.
Having an action helper which provides a large amount of functionality
would be putting too much responsibility on that class.
I suggest taking a look at separating your action helper into smaller
classes that provide more specific functionality. This will allow you
to reuse the behavior you want without having to use an action helper
in your model.
Carlo
On 2009-08-21, at 9:27 AM, "Vibhor Singh" <[email protected]> wrote:
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:[email protected]]
Sent: Friday, August 21, 2009 5:25 PM
To: Zend Framework MVC; [email protected]
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