2010年1月28日星期四

[fw-mvc] Setting Zend_Currency in registry, but it's not available to the view

I have been trying to implement the view currency helper using the
example in the manual. I have created a resource with the following
code:

class My_Bootstrap_Resource_Currency extends
Zend_Application_Resource_ResourceAbstract
{
public function init()
{
Zend_Registry::set('Zend_Currency', new Zend_Currency('en_US'));
}
}

In my application.ini, I added this line:

resources.currency = true


As per the example in the manual, I should now be able to use the helper thusly:

<?php
// view script
echo $this->currency(1342.67);
?>

However, i get this error:

Message: Plugin by name 'Currency' was not found in the registry; used
paths: Zend_Dojo_View_Helper_: Zend/Dojo/View/Helper/
Zend_View_Helper_:
Zend/View/Helper/:/home/garlinto/frontend/views/helpers/

So I thought, maybe the resource isn't being invoked. So in the
controller I ran this code:

$currency = Zend_Registry::get('Zend_Currency');
$this->view->debug = Zend_Debug::dump($currency, "Currency:", false);

And the response is:

Currency: object(Zend_Currency)#43 (2) {
["_locale:private"] => string(5) "en_US"
["_options:protected"] => array(8) {
["position"] => int(8)
["script"] => NULL
["format"] => NULL
["display"] => int(2)
["precision"] => int(2)
["name"] => string(9) "US Dollar"
["currency"] => string(3) "USD"
["symbol"] => string(1) "$"
}
}

Anyone know what I am doing wrong? I'm sure I'm missing something...

--regards,

Nathan Garlington

没有评论: