本文整理汇总了PHP中Zend_Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Registry::set方法的具体用法?PHP Zend_Registry::set怎么用?PHP Zend_Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Registry
的用法示例。
在下文中一共展示了Zend_Registry::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initLogs
protected function _initLogs()
{
$logger = new Zend_Log();
$fireBugWriter = new Zend_Log_Writer_Firebug();
$logger->addWriter($fireBugWriter);
Zend_Registry::set('logger', $logger);
}
示例2: _initLogger
protected function _initLogger()
{
$logger = $this->bootstrapLog()->getResource('Log');
/*if (! $this->hasPluginResource ( 'Log' )) {
return false;
}*/
switch (strtolower(APPLICATION_ENV)) {
case 'production':
$writer = new Zend_Log_Writer_Firebug();
$filter = new Zend_Log_Filter_Priority(5, '>=');
$writer->addFilter($filter);
// Uncomment and alter following line if you want to get more then message.
//$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE');
$logger->addWriter($writer);
break;
case 'staging':
//Not considered yet.
break;
case 'testing':
//Not considered yet.
break;
case 'development':
$writer = new Zend_Log_Writer_Firebug();
$filter = new Zend_Log_Filter_Priority(2, '>=');
$writer->addFilter($filter);
// Uncomment and alter following line if you want to get more then message.
//$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE');
$logger->addWriter($writer);
break;
default:
throw new Zend_Exception('Unknown <b>Application Environment</b> to create log writer in bootstrap.', Zend_Log::WARN);
}
// Now set logger globally in application.
Zend_Registry::set("logger", $logger);
}
示例3: _initConfig
protected function _initConfig()
{
$aConfig = $this->getOptions();
Zend_Registry::set('facebook_client_id', $aConfig['facebook']['client_id']);
Zend_Registry::set('facebook_client_secret', $aConfig['facebook']['client_secret']);
Zend_Registry::set('facebook_redirect_uri', $aConfig['facebook']['redirect_uri']);
}
示例4: getTranslate
/**
* Retrieve translate object
*
* @return Zend_Translate
* @throws Zend_Application_Resource_Exception if registry key was used
* already but is no instance of Zend_Translate
*/
public function getTranslate()
{
if (null === $this->_translate) {
$options = $this->getOptions();
if (!isset($options['data'])) {
// require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception('No translation source data provided.');
}
$adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
$locale = isset($options['locale']) ? $options['locale'] : null;
$translateOptions = isset($options['options']) ? $options['options'] : array();
$key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
if (Zend_Registry::isRegistered($key)) {
$translate = Zend_Registry::get($key);
if (!$translate instanceof Zend_Translate) {
// require_once 'Zend/Application/Resource/Exception.php';
throw new Zend_Application_Resource_Exception($key . ' already registered in registry but is ' . 'no instance of Zend_Translate');
}
$translate->addTranslation($options['data'], $locale, $options);
$this->_translate = $translate;
} else {
$this->_translate = new Zend_Translate($adapter, $options['data'], $locale, $translateOptions);
Zend_Registry::set($key, $this->_translate);
}
}
return $this->_translate;
}
示例5: getLocale
/**
* Retrieve locale object
*
* @return Zend_Locale
*/
public function getLocale()
{
if (null === $this->_locale) {
$options = $this->getOptions();
if (!isset($options['default'])) {
$this->_locale = new Zend_Locale();
} elseif(!isset($options['force']) ||
(bool) $options['force'] == false)
{
// Don't force any locale, just go for auto detection
Zend_Locale::setDefault($options['default']);
$this->_locale = new Zend_Locale();
} else {
$this->_locale = new Zend_Locale($options['default']);
}
$key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
? $options['registry_key']
: self::DEFAULT_REGISTRY_KEY;
Zend_Registry::set($key, $this->_locale);
}
return $this->_locale;
}
示例6: _setupService
/**
* Setup Akismet
*
* @param array $options
* @return Zend_Service_Akismet
*/
protected function _setupService($options)
{
if (!isset($options['apiKey'])) {
$message = 'option "apiKey" not found for Service_Akismet';
throw new Robo47_Application_Resource_Exception($message);
}
if (!isset($options['blog'])) {
$message = 'option "blog" not found for Service_Akismet';
throw new Robo47_Application_Resource_Exception($message);
}
$akismet = new Zend_Service_Akismet($options['apiKey'], $options['blog']);
if (isset($options['charset'])) {
$akismet->setCharset($options['charset']);
}
if (isset($options['userAgent'])) {
$akismet->setUserAgent($options['userAgent']);
}
if (isset($options['port'])) {
// casting needed because of is_int in Zend_Service_Akismet::setPort
$akismet->setPort((int) $options['port']);
}
if (isset($options['registryKey'])) {
Zend_Registry::set($options['registryKey'], $akismet);
}
return $akismet;
}
示例7: _initDoctrineEntityManager
public function _initDoctrineEntityManager()
{
$this->bootstrap(array('classLoaders'));
$zendConfig = $this->getOptions();
// parameters required for connecting to the database.
// the required attributes are driver, host, user, password and dbname
$connectionParameters = $zendConfig['doctrine']['connectionParameters'];
// now initialize the configuration object
$configuration = new DoctrineConfiguration();
// the metadata cache is used to avoid parsing all mapping information every time
// the framework is initialized.
//$configuration->setMetadataCacheImpl($this->getResource('doctrineCache'));
//// for performance reasons, it is also recommended to use a result cache
//$configuration->setResultCacheImpl($this->getResource('doctrineCache'));
// if you set this option to true, Doctrine 2 will generate proxy classes for your entities
// on the fly. This has of course impact on the performance and should therefore be disabled
// in the production environment
$configuration->setAutoGenerateProxyClasses($zendConfig['doctrine']['autoGenerateProxyClasses']);
// the directory, where your proxy classes live
$configuration->setProxyDir($zendConfig['doctrine']['proxyPath']);
// the proxy classes' namespace
$configuration->setProxyNamespace($zendConfig['doctrine']['proxyNamespace']);
// the next option tells doctrine which description language we want to use for the mapping
// information
$configuration->setMetadataDriverImpl($configuration->newDefaultAnnotationDriver($zendConfig['doctrine']['entityPath']));
// next, we create an event manager
$eventManager = new DoctrineEventManager();
// now we have everything required to initialize the entity manager
$entityManager = DoctrineEntityManager::create($connectionParameters, $configuration, $eventManager);
Zend_Registry::set('em', $entityManager);
return $entityManager;
}
示例8: setUp
public function setUp()
{
parent::setUp();
// All tests are done with local paths to simplify them (no http layer).
if ($this->_allowLocalPaths) {
$settings = (object) array('local_folders' => (object) array('allow' => '1', 'check_realpath' => '0', 'base_path' => TEST_FILES_DIR));
Zend_Registry::set('oai_pmh_static_repository', $settings);
} else {
$settings = (object) array('local_folders' => (object) array('allow' => '0', 'check_realpath' => '0', 'base_path' => '/var/path/to/the/folder'));
Zend_Registry::set('oai_pmh_static_repository', $settings);
}
defined('TEST_FILES_WEB') or define('TEST_FILES_WEB', WEB_ROOT . DIRECTORY_SEPARATOR . basename(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'suite' . DIRECTORY_SEPARATOR . '_files');
$pluginHelper = new Omeka_Test_Helper_Plugin();
// ArchiveDocument is a required plugin.
$path = PLUGIN_DIR . DIRECTORY_SEPARATOR . 'ArchiveDocument' . DIRECTORY_SEPARATOR . 'ArchiveDocumentPlugin.php';
$this->assertTrue(is_file($path) && filesize($path), __('This plugin requires ArchiveDocument.'));
$pluginHelper->setUp('ArchiveDocument');
$pluginHelper->setUp(self::PLUGIN_NAME);
// OcrElementSet is an optional plugin, but required for some tests.
try {
$pluginHelper->setUp('OcrElementSet');
} catch (Omeka_Plugin_Loader_Exception $e) {
}
// Allow extensions "xml" and "json".
$whiteList = get_option(Omeka_Validate_File_Extension::WHITELIST_OPTION) . ',xml,json';
set_option(Omeka_Validate_File_Extension::WHITELIST_OPTION, $whiteList);
// Allow media types for "xml" and "json".
$whiteList = get_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION) . ',application/xml,text/xml,application/json';
set_option(Omeka_Validate_File_MimeType::WHITELIST_OPTION, $whiteList);
}
开发者ID:Daniel-KM,项目名称:OaiPmhStaticRepository,代码行数:30,代码来源:OaiPmhStaticRepository_Test_AppTestCase.php
示例9: _initApiServer
protected function _initApiServer()
{
$server = new Cosmos_Api_Server(new Cosmos_Api_Request_Http());
Zend_Registry::set('server', $server);
var_dump($server->handle());
die('done');
}
示例10: Zend_Log_Writer_Firebug
/**
* Retrieve service object instance
*
* @param Zend_Config $config
* @return Zend_Translate
*/
public function &getService($config)
{
if (!$this->service) {
Zend_Translate::setCache(Zoo::getService('cache')->getCache('translate'));
/*
* @todo Re-enable this with configuration options instead of hardcoding
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$this->service = new Zend_Translate('gettext',
ZfApplication::$_base_path."/app/Zoo/Language",
null,
array(
'scan' => Zend_Translate::LOCALE_FILENAME,
'disableNotices' => true,
'log' => $logger,
'logUntranslated' => true)
);
*/
if ($config->language->default) {
$locale = new Zend_Locale($config->language->default);
Zend_Registry::set("Zend_Locale", $locale);
} else {
$locale = new Zend_Locale("en");
}
$this->service = new Zend_Translate('gettext', ZfApplication::$_base_path . "/app/Zoo/Language", $locale, array('scan' => Zend_Translate::LOCALE_FILENAME, 'disableNotices' => true));
}
return $this->service;
}
示例11: _initUrl
protected function _initUrl()
{
$port = !APPLICATION_SSL && $_SERVER['SERVER_PORT'] == STANDARD_PORT || APPLICATION_SSL && $_SERVER['SERVER_PORT'] == SSL_PORT ? '' : ':' . $_SERVER['SERVER_PORT'];
$url = APPLICATION_PROTOCOL . '://' . $_SERVER['SERVER_NAME'] . $port . APPLICATION_BASE_URL;
Zend_Registry::set('siteUrl', $url);
Zend_Registry::set('baseUrl', APPLICATION_BASE_URL);
}
示例12: _initSyslog
/**
* Bootstrap logging
*/
protected function _initSyslog()
{
// Zend_Log
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . "/tmp/log/si.log");
$logger = new Zend_Log($writer);
Zend_Registry::set('logger', $logger);
}
示例13: run
public static function run()
{
#echo get_include_path();
#exit();
try {
// 設定ファイル読み込み
$config = new Zend_Config_Ini(INSTALL_DIR . 'application/configs/config.ini', 'production');
// Zend_Loader の設定(ファイル自動読み込み)
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
Zend_Registry::set($config->registry->config, $config);
$view = new Tokyofr_View_Smarty($config->smarty->template_dir, $config->smarty->toArray());
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view)->setViewBasePathSpec($view->getEngine()->template_dir[0]);
$viewRenderer->setViewScriptPathSpec(':controller/:action.:suffix');
$viewRenderer->setViewScriptPathNoControllerSpec(':action.:suffix');
$viewRenderer->setViewSuffix('phtml');
Tokyofr_Controller_Front::run($config->path->controller);
} catch (Zend_Exception $e) {
//var_dump($e->getMessage());
exit("error.");
} catch (Exception $e) {
//var_dump($e->getMessage());
exit('error02');
}
}
示例14: init
public function init()
{
if (null === $this->_locale) {
$sessionLocale = new Zend_Session_Namespace('locale');
//Zend_Session::destroy();
//var_dump($session->localename);
//Zend_Debug::dump($_SESSION);exit;
//Zend_Debug::dump(Zend_Session::getOptions());exit;
if (isset($sessionLocale->localename)) {
$this->_locale = new Zend_Locale($sessionLocale->localename);
} else {
$options = $this->getOptions();
if (!isset($options['default'])) {
$this->_locale = new Zend_Locale();
} elseif (!isset($options['force']) || (bool) $options['force'] == false) {
// Don't force any locale, just go for auto detection
Zend_Locale::setDefault($options['default']);
$this->_locale = new Zend_Locale();
} else {
//强制区域为...
$this->_locale = new Zend_Locale($options['default']);
}
$sessionLocale->localename = $this->_locale->getLanguage() . '_' . $this->_locale->getRegion();
}
$key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
Zend_Registry::set($key, $this->_locale);
Zend_Registry::set('sessionLocale', $sessionLocale);
}
return $this->_locale;
}
示例15: __invoke
/**
* @param \HumusMvc\MvcEvent $e
* @return void
*/
public function __invoke(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$config = $serviceManager->get('Config');
if (!isset($config['locale'])) {
// no locale config found, return
return;
}
// set cache in locale to speed up application
if ($serviceManager->has('CacheManager')) {
$cacheManager = $serviceManager->get('CacheManager');
Locale::setCache($cacheManager->getCache('default'));
}
$options = $config['locale'];
if (!isset($options['default'])) {
$locale = new Locale();
} elseif (!isset($options['force']) || (bool) $options['force'] == false) {
// Don't force any locale, just go for auto detection
Locale::setDefault($options['default']);
$locale = new Locale();
} else {
$locale = new Locale($options['default']);
}
$key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
Registry::set($key, $locale);
}