Issues

ZF-7058: Zend_Application Locale Resource - set cache via config

Description

It would be nice to have posibility to set zend locale cache via application.ini config file

Comments

I think this already works...

resources.locale.default = en_US

Could you please elaborate your request? I'm not sure I follow.

Closing as 'incomplete' as for it's unclear (read: real vague) what is asked for here.

I think this was about ability to add in config file (application.ini) something like this:

resources.locale.cache = ""locale"

and this cache named "locale" can be defined by/in cachemanager also using config file (application.ini)

resources.cachemanager.locale.frontend.name = Core etc...

This patch should give the desired functionality

*** library/Zend/Application/Resource/Locale.php 2010-02-01 21:13:08.000000000 +0100 --- library/Zend/Application/Resource/Locale.php 2011-02-03 15:33:05.375000092 +0100


*** 86,89 **** --- 86,121 ----

      return $this->_locale;
  }

+
+ /** + * Set the locale cache + * + * @param string|Zend_Cache_Core $cache + * @return Zend_Application_Resource_Locale + */ + public function setCache($cache) + { + $localeCache = null; + + if (is_string($cache)) { + $bootstrap = $this->getBootstrap(); + if ($bootstrap instanceof Zend_Application_Bootstrap_ResourceBootstrapper + && $bootstrap->hasPluginResource('CacheManager') + ) { + $cacheManager = $bootstrap->bootstrap('CacheManager') + ->getResource('CacheManager'); + if (null !== $cacheManager && $cacheManager->hasCache($cache)) { + $localeCache = $cacheManager->getCache($cache); + } + } + } else if ($cache instanceof Zend_Cache_Core) { + $localeCache = $cache; + } + + if ($localeCache instanceof Zend_Cache_Core) { + Zend_Locale::setCache($localeCache); + } + + return $this; + }
}

See the alternative proposed at 10720. The way that I suggested (not as patch for laziness) gives the opportunity to use a more generally available cache:


; ...
resources.cachemanager.myCache.frontend.name = Core
...
resources.locale.cache = "myCache"
; ...

I think that a 'merge' between the two solutions should be used.

Regards, Sergio

@Pawe? Szczekutowicz, we can not use a patch if you have not signed CLA.

I will follow the code I made for other resources (#ZF-10033, #ZF-10034, and #ZF-10049). I forgot that Zend_Locale also had a cache too.

Fixed in r23747.

Including in 1.11.4 release.