2009年9月24日星期四

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

I don't want to render it yet, I just want to know whether I should add the partial or the action to my $return_value. The point is that the website has two containers, and within these containers, per page, the customer needs to sort these containers via the CMS. We've created a symfony plugin for symfony projects and those all work great. However, as I am trying to implement this database/CMS structure to my ZF project, I need to know whether it's a action or a partial. True, I can also add a field to the databse in which I say whether it's a partial or an action, but this is not our default and a quick 'actionExists' or 'isAction' or 'partialExists' or 'isPartial' would do the trick anyway ;-)

Hector Virgen schreef:
I believe $view->render() will throw an exception if the view script could not be found. This may save you from having to run file_exists() and will automatically use the registered view script paths.

As far as the action is concerned, I think Mert is right, but there might be better ways.

Just curious -- why not store the actual information in the database? It would save you from writing tests if you knew how to call it.

--
Hector


On Thu, Sep 24, 2009 at 4:33 AM, Mert Oztekin <moztekin@anadolusigorta.com.tr> wrote:
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.



没有评论: