Hi there,
Without knowing what your custom helper actually does, I guess you
could take this in a couple of directions:
- You could refactor it so that the functionality in the Custom Helper
Class is in the Model, If you have controller specific logic, then
perhaps you can create another Action Helper to bridge that gap.
- If the functionality is custom helper code is a generic and not so
specific that you can encapsulate it inside the model, you'd make this a
resource or part of your custom library and call upon it that way, your
Custom Helper would be replaced by a "factory method" in the Controller
and the Model can access this functionality too.
HTH
regards,
Ronald Villar David
Technical Lead, DevProducts Pty Ltd
5/89 Derby St, Silverwater NSW, Australia 2128
w: http://www.devproducts.com | b: http://devproducts.blogspot.com
Vibhor Singh 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
begin:vcard
fn:Ronald Villar David
n:David;Ronald Villar
org:Devproducts Pty Ltd;Web Development
adr:89 Derby Street;;Unit 5;SILVERWATER;NSW;2128;Australia
email;internet:[email protected]
title:Technical Lead
tel;work:+612 9648 3777
tel;fax:+612 9648 6988
url:http://www.devproducts.com
version:2.1
end:vcard