2009年9月26日星期六

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

On Thursday 24 September 2009 23:34:01 Dimitri van Hees wrote:
>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.
>

$front = Zend_Controller_Front::getInstance();
$dispatcher = $front->getDispatcher();

$test = new Zend_Controller_Request_Http()
$test->setParams(array(
'action' => 'foo',
'controller' => 'bar',
'module' => 'baz'
)
);

if($dispatcher->isDispatchable($test) {
// action method exists
} else {
// no action method, use partial
}

--
"Experience is the name everyone gives to their mistakes."
☘ Oscar Wilde

没有评论: