本文整理汇总了PHP中Zend_Registry::setInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Registry::setInstance方法的具体用法?PHP Zend_Registry::setInstance怎么用?PHP Zend_Registry::setInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Registry
的用法示例。
在下文中一共展示了Zend_Registry::setInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupRegistry
public static function setupRegistry()
{
self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
Zend_Registry::setInstance(self::$registry);
$registry = Zend_Registry::getInstance();
$registry->set('root', self::$root);
}
示例2: getRegistry
/**
* @return \Zend_Registry
*/
protected function getRegistry()
{
if (null == $this->registry) {
$this->registry = new \Zend_Registry(array(), \ArrayObject::ARRAY_AS_PROPS);
\Zend_Registry::setInstance($this->registry);
}
return $this->registry;
}
示例3: setInstance
/**
* Set the default registry instance to a specified instance.
*
* @param Zend_Registry $registry An object instance of type Zend_Registry,
* or a subclass.
* @return void
* @throws Zend_Exception if registry is already initialized.
*/
public static function setInstance(Zend_Registry $registry)
{
if (self::$_registry !== null) {
// require_once 'Zend/Exception.php';
throw new Zend_Exception('Registry is already initialized');
}
parent::setInstance($registry);
self::$_registryClassName = get_class($registry);
self::$_registry = $registry;
}
示例4: _initRegistry
/**
* Initilize the Zend Registry
* @return Zend_Registry
*/
protected function _initRegistry()
{
$registry = new Zend_Registry();
// List of all US states
$registry["us_states"] = array('AL' => "Alabama", 'AK' => "Alaska", 'AZ' => "Arizona", 'AR' => "Arkansas", 'CA' => "California", 'CO' => "Colorado", 'CT' => "Connecticut", 'DE' => "Delaware", 'DC' => "District Of Columbia", 'FL' => "Florida", 'GA' => "Georgia", 'HI' => "Hawaii", 'ID' => "Idaho", 'IL' => "Illinois", 'IN' => "Indiana", 'IA' => "Iowa", 'KS' => "Kansas", 'KY' => "Kentucky", 'LA' => "Louisiana", 'ME' => "Maine", 'MD' => "Maryland", 'MA' => "Massachusetts", 'MI' => "Michigan", 'MN' => "Minnesota", 'MS' => "Mississippi", 'MO' => "Missouri", 'MT' => "Montana", 'NE' => "Nebraska", 'NV' => "Nevada", 'NH' => "New Hampshire", 'NJ' => "New Jersey", 'NM' => "New Mexico", 'NY' => "New York", 'NC' => "North Carolina", 'ND' => "North Dakota", 'OH' => "Ohio", 'OK' => "Oklahoma", 'OR' => "Oregon", 'PA' => "Pennsylvania", 'RI' => "Rhode Island", 'SC' => "South Carolina", 'SD' => "South Dakota", 'TN' => "Tennessee", 'TX' => "Texas", 'UT' => "Utah", 'VT' => "Vermont", 'VA' => "Virginia", 'WA' => "Washington", 'WV' => "West Virginia", 'WI' => "Wisconsin", 'WY' => "Wyoming");
// Load our configuration file
$registry["config"] = new Zend_Config_Ini(APPLICATION_PATH . "/configs/config.ini", APPLICATION_ENV);
// US Timezones
$registry["timezones"] = array("America/Juneau" => "Alaska", "America/Phoenix" => "Arizona", "Pacific/Honolulu" => "Hawaii-Aleutian", "America/Seattle" => "Pacific", "America/Denver" => "Mountain", "America/Chicago" => "Central", "America/New_York" => "Eastern", "America/Manaus" => "Atlantic");
Zend_Registry::setInstance($registry);
return $registry;
}
示例5: testRegistryExceptionAlreadyInitialized
public function testRegistryExceptionAlreadyInitialized()
{
$registry = Zend_Registry::getInstance();
try {
Zend_Registry::setClassName('anyclass');
$this->fail('Expected exception, because we cannot initialize the registry if it is already initialized.');
} catch (Zend_Exception $e) {
$this->assertContains('Registry is already initialized', $e->getMessage());
}
try {
Zend_Registry::setInstance(new Zend_Registry());
$this->fail('Expected exception, because we cannot initialize the registry if it is already initialized.');
} catch (Zend_Exception $e) {
$this->assertContains('Registry is already initialized', $e->getMessage());
}
}
示例6: setupRegistry
/**
* Setup the application registry.
*/
public static function setupRegistry()
{
// Create an instance of the registry.
self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
// Set the default instance.
Zend_Registry::setInstance(self::$registry);
}
示例7: error_reporting
<?php
error_reporting(E_ALL);
defined('ROOT_PATH') || define('ROOT_PATH', realpath(dirname(__FILE__)));
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
define('INI_PATH', '/configs/application.ini');
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Zend/Registry.php';
require_once APPLICATION_PATH . "/common/Common.php";
$registry = new Zend_Registry(array('index' => $value));
Zend_Registry::setInstance($registry);
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . INI_PATH);
$application->bootstrap()->run();
示例8: _initializeRegistry
/**
* Initializes the Zend_Registry
*
* Was Part of main initialize method
*
* @access private
* @static
* @return boolean
*/
private static function _initializeRegistry()
{
$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
Zend_Registry::setInstance($registry);
return $registry;
}