> Jason DeBord wrote:
>
>> If I create an object in my bootstrap file, how do I access it in a
>> Controller.
>>
>> For example:
>>
>> Bootstrap:
>>
>> ...
>>
>> $locale = new Zend_Locale;
>>
>> ...
>>
>> IndexController:
>>
>> <?php
>>
>> class IndexController extends Zend_Controller_Action {
>>
>> public function init() {
>>
>> $locale->setLocale('fr_FR');
>>
>> }
>>
>> public function indexAction() {
>>
>>
>> }
>>
>> }
>>
>> The above does not seem to work.
>>
>> I'm just starting to use ZF, so thanks for the help!
>>
>> Thanks!
>>
>> Jason DEBORD
>> Limoges, France
>>
>
> The most common way is to store them in the registry:
>
> Bootstrap:
> ...
> $locale = new Zend_Locale;
> Zend_Registry::set('locale', $locale);
>
Right way here is:
Zend_Registry::getInstance()->set('locale', $locale);
> ...
>
>
> Controller:
> ...
> $locale = Zend_Registry::get('locale');
> $locale->setLocale('fr_FR');
> ...
>
>
--
Thanks,
Yaroslav Vorozhko, Software Engeneer, Consultant
Skype: yarik0083
AIM: yarik0083
ICQ: 148966172
My blog: http://pro100pro.com
Web-design firm: http://vdesign.com.ua
Attend the 2009 Percona Performance Conf
Apr 22-23 http://conferences.percona.com/
没有评论:
发表评论