2009年9月24日星期四

RE: [fw-mvc] how to check if action or partial exists?

May be it is the worst answer that can be given, but this should work : you can try method_exists() function to look if barAction exists in YourClass_Bar. And if false, you can check if 'bar.phtml' file exists with file_exists() function.

This should work. But there should be a much better answer.

-----Original Message-----
From: Dimitri van Hees [mailto:dimitri@freshheads.com]
Sent: Thursday, September 24, 2009 2:29 PM
To: fw-mvc@lists.zend.com
Subject: [fw-mvc] how to check if action or partial exists?

Hi,

I am working on a view helper that loops through a set of given
controller/action values. The rank of this set can be modified by the
user (it's stored in the database). However, not everything needs to be
a 'real' action. It could also be a partial, like a single banner. I
would still like to use the same pairs of data, stating that if the
action 'bar' exists in controller 'foo', I am going to output
$this->view->action('bar','foo'). If it doesn't exist, I'd like to check
if there is a partial called 'foor/bar.phtml' and eventually output
$this->view->partial('foor/bar.phtml'). If this also doesn't exist, I'd
like to throw an exception.

However, I can't find any possibility to check whether a partial or an
action in a given controller exists (from within my view helper or
anywhere else). Can anyone tell me if this is possible at all, and if it
is, how? Thanks in advance!

Kind regards,

Dimitri van Hees


Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.

没有评论: