开发者

Zend Controller Action , get Helper in other class?

开发者 https://www.devze.com 2022-12-14 13:37 出处:网络
is there any way to get an Action Helper from an Service Class? I have the following Helper: class Helper_Host extends Zend_Controller开发者_StackOverflow_Action_Helper_Abstract

is there any way to get an Action Helper from an Service Class?

I have the following Helper:

class Helper_Host extends Zend_Controller开发者_StackOverflow_Action_Helper_Abstract
{
    /**
     * Return Hosturl with path
     *
     * @return string Hostname
     */
    public function direct()
    {
        $front = Zend_Controller_Front::getInstance();
        $host = 'http://' . $_SERVER['HTTP_HOST'];
        $host .= $front->getBaseUrl() . '/';
        return (string) $host;
    }
}

Now i want to get the Hostname from "My_Service_XYZ" , getStaticHelper is not working like excepted (;

class My_Service_XYZ {

    public function test()
    {
        $h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host');
        return $h->host(); // not working..
    }

}


    class My_Service_XYZ {

        public function test()
        {
            $h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host');
            return $h->direct(); // not working..
        }

    }

should works


Maybe you should try:

$h = Zend_Controller_Action_HelperBroker::getStaticHelper('Host');

instead of:

$h = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号