本文整理汇总了PHP中Zend\Registry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::get方法的具体用法?PHP Registry::get怎么用?PHP Registry::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Registry
的用法示例。
在下文中一共展示了Registry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor for the integer validator
*
* Accepts either a string locale, a Zend_Locale object, or an array or
* Zend_Config object containing the keys "locale" and/or "format".
*
* @param string|Zend_Locale|array|\Zend\Config\Config $options
* @throws \Zend\Validator\Exception On empty format
*/
public function __construct($options = null)
{
if ($options instanceof \Zend\Config\Config) {
$options = $options->toArray();
}
if (empty($options)) {
if (\Zend\Registry::isRegistered('Zend_Locale')) {
$this->setLocale(\Zend\Registry::get('Zend_Locale'));
}
} elseif (is_array($options)) {
// Received
if (array_key_exists('locale', $options)) {
$this->setLocale($options['locale']);
}
if (array_key_exists('format', $options)) {
$this->setFormat($options['format']);
}
} elseif ($options instanceof Locale\Locale || is_string($options)) {
// Received Locale object or string locale
$this->setLocale($options);
}
$format = $this->getFormat();
if (empty($format)) {
throw new Exception\InvalidArgumentException("A postcode-format string has to be given for validation");
}
}
示例2: __construct
/**
* Sets validator options
*
* @param null|string|Locale|array|Traversable $locale OPTIONAL
* @return void
*/
public function __construct($locale = null)
{
$options = array();
if ($locale instanceof Traversable) {
$locale = IteratorToArray::convert($locale);
}
if (is_array($locale)) {
$options = $locale;
if (array_key_exists('locale', $locale)) {
$locale = $locale['locale'];
unset($options['locale']);
} else {
$locale = null;
}
}
if (empty($locale) && $locale !== false) {
if (Registry::isRegistered('Zend_Locale')) {
$locale = Registry::get('Zend_Locale');
}
}
if ($locale !== null) {
$this->setLocale($locale);
}
parent::__construct($options);
}
示例3: __construct
/**
* Sets validator options
*
* @param string|array|Traversable $options OPTIONAL
* @return void
*/
public function __construct($options = array())
{
if ($options instanceof Traversable) {
$options = IteratorToArray::convert($options);
} elseif (!is_array($options)) {
$options = func_get_args();
$temp['format'] = array_shift($options);
if (!empty($options)) {
$temp['locale'] = array_shift($options);
}
$options = $temp;
}
if (array_key_exists('format', $options)) {
$this->setFormat($options['format']);
}
if (!array_key_exists('locale', $options)) {
if (Registry::isRegistered('Zend_Locale')) {
$options['locale'] = Registry::get('Zend_Locale');
}
}
if (array_key_exists('locale', $options)) {
$this->setLocale($options['locale']);
}
parent::__construct($options);
}
示例4: __construct
/**
* Constructor for manually handling
*
* @param \Zend\Currency\Currency $currency Instance of \Zend\Currency\Currency
* @return void
*/
public function __construct($currency = null)
{
if ($currency === null) {
if (\Zend\Registry::isRegistered('Zend_Currency')) {
$currency = \Zend\Registry::get('Zend_Currency');
}
}
$this->setCurrency($currency);
}
示例5: testOptionsPassedToResourceAreUsedToSetLocaleState
public function testOptionsPassedToResourceAreUsedToSetLocaleState()
{
$resource = new TranslateResource($this->_translationOptions);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$translate = $resource->getTranslate();
$this->assertTrue(Registry::isRegistered('Zend_Translate'));
$this->assertSame(Registry::get('Zend_Translate'), $translate);
}
示例6: testMultiplePlaceholdersUseSameRegistry
public function testMultiplePlaceholdersUseSameRegistry()
{
$this->assertTrue(Registry::isRegistered(PlaceholderRegistry::REGISTRY_KEY));
$registry = Registry::get(PlaceholderRegistry::REGISTRY_KEY);
$this->assertSame($registry, $this->placeholder->getRegistry());
$placeholder = new Helper\Placeholder();
$this->assertSame($registry, $placeholder->getRegistry());
$this->assertSame($this->placeholder->getRegistry(), $placeholder->getRegistry());
}
示例7: getRegistry
/**
* Retrieve or create registry instnace
*
* @return void
*/
public static function getRegistry()
{
if (\Zend\Registry::isRegistered(self::REGISTRY_KEY)) {
$registry = \Zend\Registry::get(self::REGISTRY_KEY);
} else {
$registry = new self();
\Zend\Registry::set(self::REGISTRY_KEY, $registry);
}
return $registry;
}
示例8: __construct
/**
* Constructor
*
* Map constants to doctype strings, and set default doctype
*/
public function __construct()
{
if (!Registry::isRegistered($this->_regKey)) {
$this->_registry = new ArrayObject(array('doctypes' => array(self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', self::XHTML1_RDFA1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">', self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', self::XHTML1_FRAMESET => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', self::XHTML_BASIC1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">', self::XHTML5 => '<!DOCTYPE html>', self::HTML4_STRICT => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', self::HTML4_LOOSE => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', self::HTML4_FRAMESET => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', self::HTML5 => '<!DOCTYPE html>')));
Registry::set($this->_regKey, $this->_registry);
$this->setDoctype($this->_defaultDoctype);
} else {
$this->_registry = Registry::get($this->_regKey);
}
}
示例9: testOptionsPassedToResourceAreUsedToSetLocaleState1
public function testOptionsPassedToResourceAreUsedToSetLocaleState1()
{
$this->markTestSkipped('Skipped until Zend\\Locale and the Resource can be further examined. Logic in the resource and in Locale do not match up.');
$options = array('default' => 'kok_IN');
$resource = new LocaleResource($options);
$resource->setBootstrap($this->bootstrap);
$resource->init();
$locale = $resource->getLocale();
var_dump($locale->__toString());
// This test will fail if your configured locale is kok_IN
$this->assertFalse('kok_IN' == $locale->__toString());
$this->assertSame(Registry::get('Zend_Locale'), $locale);
}
示例10: array
function __construct()
{
$this->open_connection();
$this->magic_quotes_active = get_magic_quotes_gpc();
$this->real_escape_string_exists = function_exists("mysql_real_escape_string");
// $this->cache = new Memcache();
// $this->cache->connect(CACHE_SERVER, CACHE_PORT) or die ("Could not connect");
$this->zend_cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 3600 * 24, 'automatic_serialization' => true), array('cache_dir' => SITE_ROOT . '/cache_files'));
Zend_Registry::set('cached', $this->zend_cache);
//<---set a registry refference
$this->zend_cache = Zend_Registry::get('cached');
//<---gets the a registry refference
}
示例11: __construct
/**
* Constructor
*
* @param string $value
* @param array $columns
* @param array|string $cache
* @param string $criteria
*/
public function __construct($value, $columns, $cache, $criteria = self::CRITERIA_BEGINS)
{
parent::__construct($columns, $value);
if (empty($cache)) {
$this->_cache = false;
} elseif (is_array($cache)) {
$this->_cache = $cache;
} else {
$this->_cache = \Zend\Registry::get($cache);
}
$this->_criteria = $criteria;
$this->_setValue();
}
示例12: __construct
/**
* Constructor for the integer validator
*
* Accepts either a string locale, a Zend_Locale object, or an array or
* Zend_Config object containing the keys "locale" and/or "format".
*
* @param string|Zend_Locale|array|\Zend\Config\Config $options
* @throws \Zend\Validator\Exception On empty format
*/
public function __construct($options = null)
{
if (empty($options)) {
if (\Zend\Registry::isRegistered('Zend_Locale')) {
$this->setLocale(\Zend\Registry::get('Zend_Locale'));
}
} elseif ($options instanceof Locale\Locale || is_string($options)) {
// Received Locale object or string locale
$this->setLocale($options);
}
parent::__construct($options);
$format = $this->getFormat();
if (empty($format)) {
throw new Exception\InvalidArgumentException("A postcode-format string has to be given for validation");
}
}
示例13: testShouldProxyToMenuHelperByDeafult
public function testShouldProxyToMenuHelperByDeafult()
{
// setup
$oldReg = null;
if (\Zend\Registry::isRegistered(self::REGISTRY_KEY)) {
$oldReg = \Zend\Registry::get(self::REGISTRY_KEY);
}
\Zend\Registry::set(self::REGISTRY_KEY, $this->_nav1);
$this->_helper->setContainer(null);
// result
$expected = $this->_getExpected('menu/default1.html');
$actual = $this->_helper->render();
// teardown
\Zend\Registry::set(self::REGISTRY_KEY, $oldReg);
$this->assertEquals($expected, $actual);
}
示例14: __construct
/**
* Constructor for the float validator
*
* @param string|Zend_Config|\Zend\Locale\Locale $locale
*/
public function __construct($locale = null)
{
if ($locale instanceof \Zend\Config\Config) {
$locale = $locale->toArray();
}
if (is_array($locale)) {
if (array_key_exists('locale', $locale)) {
$locale = $locale['locale'];
} else {
$locale = null;
}
}
if (empty($locale)) {
if (\Zend\Registry::isRegistered('Zend_Locale')) {
$locale = \Zend\Registry::get('Zend_Locale');
}
}
$this->setLocale($locale);
}
示例15: __construct
/**
* Constructor for the integer validator
*
* @param array|Traversable|\Zend\Locale\Locale|string $options
*/
public function __construct($options = null)
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (is_array($options)) {
if (array_key_exists('locale', $options)) {
$options = $options['locale'];
} else {
$options = null;
}
}
if (empty($options)) {
if (\Zend\Registry::isRegistered('Zend_Locale')) {
$options = \Zend\Registry::get('Zend_Locale');
}
}
if ($options !== null) {
$this->setLocale($options);
}
parent::__construct();
}