0

嗨,我有一个控制器助手如下:

<?php

class Application_Controller_Helper_GetEventDetail extends Zend_Controller_Action_Helper_Abstract
{

    public function direct($eventDetail)
    {
        return $this->getEventDetail($eventDetail);
    }

    public function getEventDetail($event_id)
    {
        $eventMapper = new Application_Model_Mapper_EventMapper();      
        $eventDetails = $eventMapper->findById($event_id);
        $eventDate = $this->view->getEventTime($eventDetails[0]['date_from'],$eventDetails[0]['date_to']);

        $result = array(
            'event' => $eventDetails,
            'when' => $eventDate
            );

        return $result;

    }

}

我有一个视图助手如下getEventTime

<?php

class Application_View_Helper_GetEventTime extends Zend_View_Helper_Abstract
{

    public function getEventTime($fromdate,$todate)
    {
        //echo $to; exit;
         return date("j F Y, H:m a",strtotime($fromdate))."-<br/>".date("j F Y, H:m a",strtotime($todate));
    }
}

?>

我无法在应用程序控制器助手中访问应用程序视图助手,我可能错了!

4

1 回答 1

4

抽象类Zend_Controller_Action_Helper_Abstract不提供$view反映控制器正在使用的视图对象的属性。

如果您想从您的操作助手访问视图对象,请使用以下代码:

$view = $this->getActionController()->view;

一旦你有了它,你应该能够调用你的视图助手,比如:

$view->getEventTime(...);
于 2012-10-01T23:53:08.223 回答