当前位置: 首页>>代码示例>>PHP>>正文


PHP Registry::set方法代码示例

本文整理汇总了PHP中Zend\Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::set方法的具体用法?PHP Registry::set怎么用?PHP Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Registry的用法示例。


在下文中一共展示了Registry::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Registry::_unsetInstance();
     $this->view   = $this->getView();
     $this->helper = new DojoContainer();
     $this->helper->setView($this->view);
     Registry::set('Zend\Dojo\View\Helper\Dojo', $this->helper);
     DojoHelper::setUseProgrammatic();
 }
开发者ID:noose,项目名称:zf2,代码行数:15,代码来源:DojoTest.php

示例2: __construct

 /**
  * Constructor
  *
  * Map constants to doctype strings, and set default doctype
  *
  * @return void
  */
 public function __construct()
 {
     if (!\Zend\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_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>')));
         \Zend\Registry::set($this->_regKey, $this->_registry);
         $this->setDoctype($this->_defaultDoctype);
     } else {
         $this->_registry = \Zend\Registry::get($this->_regKey);
     }
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:17,代码来源:Doctype.php

示例3: 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;
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:15,代码来源:Registry.php

示例4: testTranslationIsAddedIfRegistryKeyExistsAlready

 /**
  * @group ZF-7352
  */
 public function testTranslationIsAddedIfRegistryKeyExistsAlready()
 {
     $options1 = array('foo' => 'bar');
     $options2 = array_merge_recursive($this->_translationOptions, array('content' => array('message4' => 'bericht4')));
     $translate = new \Zend\Translator\Translator(\Zend\Translator\Translator::AN_ARRAY, $options1);
     Registry::set('Zend_Translator', $translate);
     $resource = new TranslateResource($options2);
     $this->assertTrue($translate === $resource->getTranslate());
     $this->assertEquals('bar', $translate->translate('foo'));
     $this->assertEquals('bericht4', $translate->translate('message4'));
     $this->assertEquals('shouldNotExist', $translate->translate('shouldNotExist'));
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:15,代码来源:TranslatorTest.php

示例5: 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
 }
开发者ID:dipdumdip,项目名称:skritoos-nimgamu-parmu,代码行数:13,代码来源:database.php

示例6: getLocale

 /**
  * Retrieve locale object
  *
  * @return \Zend\Locale\Locale
  */
 public function getLocale()
 {
     if (null === $this->_locale) {
         $options = $this->getOptions();
         if (!isset($options['default'])) {
             $this->_locale = new SystemLocale\Locale();
         } elseif (!isset($options['force']) || (bool) $options['force'] == false) {
             // Don't force any locale, just go for auto detection
             SystemLocale\Locale::setDefault($options['default']);
             $this->_locale = new SystemLocale\Locale();
         } else {
             $this->_locale = new SystemLocale\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;
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:23,代码来源:Locale.php

示例7: testElementsOfSubFormReceiveCorrectDefaultTranslator

 /**
  * @group ZF-11831
  */
 public function testElementsOfSubFormReceiveCorrectDefaultTranslator()
 {
     $isEmptyKey = \Zend\Validator\NotEmpty::IS_EMPTY;
     // Global default translator
     $trDefault = new Translator(array('adapter' => 'arrayAdapter', 'content' => array($isEmptyKey => 'Default'), 'locale' => 'en'));
     Registry::set('Zend_Translate', $trDefault);
     // Translator to use for elements
     $trElement = new Translator(array('adapter' => 'arrayAdapter', 'content' => array($isEmptyKey => 'Element'), 'locale' => 'en'));
     \Zend\Validator\AbstractValidator::setDefaultTranslator($trElement);
     // Change the form's translator
     $form = new Form();
     $form->addElement(new \Zend\Form\Element\Text('foo', array('required' => true, 'validators' => array('NotEmpty'))));
     // Create a subform with it's own validator
     $sf1 = new SubForm();
     $sf1->addElement(new \Zend\Form\Element\Text('foosub', array('required' => true, 'validators' => array('NotEmpty'))));
     $form->addSubForm($sf1, 'Test1');
     $form->isValid(array());
     $messages = $form->getMessages();
     $this->assertEquals('Element', @$messages['foo'][$isEmptyKey], 'Form element received wrong validator');
     $this->assertEquals('Element', @$messages['Test1']['foosub'][$isEmptyKey], 'SubForm element received wrong validator');
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:24,代码来源:FormTest.php

示例8: testLocaleDetectsNoEnglishLocaleOnOtherSetLocale

 /**
  * @ZF-7703
  */
 public function testLocaleDetectsNoEnglishLocaleOnOtherSetLocale()
 {
     \Zend\Registry::set('Zend_Locale', new Locale\Locale('de'));
     $valid = new Validator\Int();
     $this->assertTrue($valid->isValid(1200));
     $this->assertFalse($valid->isValid('1,200'));
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:10,代码来源:IntTest.php

示例9: _storeRegistry

 /**
  * Stores navigation container in the registry
  *
  * @return void
  */
 protected function _storeRegistry()
 {
     $options = $this->getOptions();
     if (isset($options['storage']['registry']['key']) && !is_numeric($options['storage']['registry']['key'])) {
         $key = $options['storage']['registry']['key'];
     } else {
         $key = self::DEFAULT_REGISTRY_KEY;
     }
     \Zend\Registry::set($key, $this->getContainer());
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:15,代码来源:Navigation.php

示例10: testAutoloadContainerFromRegistry

    public function testAutoloadContainerFromRegistry()
    {
        $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);

        $expected = $this->_getExpected('sitemap/default1.xml');
        $actual = $this->_helper->render();

        \Zend\Registry::set(self::REGISTRY_KEY, $oldReg);

        $this->assertEquals($expected, $expected);
    }
开发者ID:noose,项目名称:zf2,代码行数:17,代码来源:SitemapTest.php

示例11: testDefaultTranslatorDoesntOverrideElementTranslatorOnValdiation

 /**
  * @group ZF-9275
  */
 public function testDefaultTranslatorDoesntOverrideElementTranslatorOnValdiation()
 {
     $registryTranslations = array('alphaInvalid' => 'Registry message');
     $registryTranslate = new Translator('ArrayAdapter', $registryTranslations);
     Registry::set('Zend_Translator', $registryTranslate);
     $validatorTranslations = array('alphaInvalid' => 'Validator message');
     $validatorTranslate = new Translator('ArrayAdapter', $validatorTranslations);
     AbstractValidator::setDefaultTranslator($validatorTranslate);
     $elementTranslations = array('alphaInvalid' => 'Element message');
     $elementTranslate = new Translator('ArrayAdapter', $elementTranslations);
     $this->element->addValidator('Alpha');
     $this->element->setTranslator($elementTranslate);
     $this->assertFalse($this->element->isValid(123));
     $messages = $this->element->getMessages();
     $this->assertEquals('Element message', $messages['alphaInvalid']);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:19,代码来源:ElementTest.php

示例12: testRegistryLocale

 /**
  * @group ZF-11631
  */
 public function testRegistryLocale()
 {
     $locale = new Locale('ja');
     \Zend\Registry::set('Zend_Locale', $locale);
     if (!self::$_unicodeEnabled) {
         $this->markTestSkipped('Unicode not enabled');
     }
     $valuesExpected = array('aABbc' => 'aBc', 'z Y x' => 'zx', 'W1v3U4t' => 'vt', ',sй.rλ:qν_p' => 'srqp', 'onml' => 'onml');
     $filter = new AlphaFilter();
     $this->assertEquals('ja', (string) $filter->getLocale());
     foreach ($valuesExpected as $input => $output) {
         $this->assertEquals($output, $result = $filter($input), "Expected '{$input}' to filter to '{$output}', but received '{$result}' instead");
     }
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:17,代码来源:AlphaTest.php

示例13: testRegistryLocale

 /**
  * testing registry Locale
  * ZF-3676
  */
 public function testRegistryLocale()
 {
     $locale = new Locale\Locale('de_AT');
     \Zend\Registry::set('Zend_Locale', $locale);
     $currency = new Currency\Currency('EUR');
     $this->assertSame('de_AT', $currency->getLocale());
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:11,代码来源:CurrencyTest.php

示例14: testGlobalTranslatorFromRegistryUsedWhenNoLocalTranslatorSet

 public function testGlobalTranslatorFromRegistryUsedWhenNoLocalTranslatorSet()
 {
     set_error_handler(array($this, 'errorHandlerIgnore'));
     $translate = new Translator\Translator('ArrayAdapter', array());
     restore_error_handler();
     \Zend\Registry::set('Zend_Translate', $translate);
     $this->assertSame($translate->getAdapter(), $this->validator->getTranslator());
 }
开发者ID:rmarshall-quibids,项目名称:zf2,代码行数:8,代码来源:StaticValidatorTest.php

示例15: testUsingApplicationLocale

 /**
  * @ZF-6374
  */
 public function testUsingApplicationLocale()
 {
     \Zend\Registry::set('Zend_Locale', new \Zend\Locale\Locale('de'));
     $valid = new Validator\Date();
     $this->assertTrue($valid->isValid('10.April.2008'));
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:9,代码来源:DateTest.php


注:本文中的Zend\Registry::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。