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


PHP Container::protect方法代码示例

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


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

示例1: testProtectShared

 /**
  * Tests the protected method when passing the shared arg..
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testProtectShared()
 {
     $this->fixture->protect('foo', function () {
         return new \stdClass();
     }, true);
     $dataStore = $this->readAttribute($this->fixture, 'dataStore');
     $this->assertTrue($dataStore['foo']['protected'], 'The protect convenience method sets items as protected.');
     $this->assertTrue($dataStore['foo']['shared'], 'The protected method does set shared when passed true as third arg.');
 }
开发者ID:ZerGabriel,项目名称:joomla-framework,代码行数:16,代码来源:ContainerTest.php

示例2: testExtendProtected

 /**
  * @testdox A protected resource can not be extended
  * @expectedException \Joomla\DI\Exception\ProtectedKeyException
  */
 public function testExtendProtected()
 {
     $container = new Container();
     $container->protect('foo', function () {
         return new \stdClass();
     });
     $value = 42;
     $container->extend('foo', function ($shared) use($value) {
         $shared->value = $value;
         return $shared;
     });
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:16,代码来源:ResourceDecorationTest.php

示例3: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     require_once JPATH_CONFIGURATION . '/configuration.php';
     $config = new Registry(new JConfig());
     // Set the error_reporting
     switch ($config->get('error_reporting')) {
         case 'default':
         case '-1':
             break;
         case 'none':
         case '0':
             error_reporting(0);
             break;
         case 'simple':
             error_reporting(E_ERROR | E_WARNING | E_PARSE);
             ini_set('display_errors', 1);
             break;
         case 'maximum':
             error_reporting(E_ALL);
             ini_set('display_errors', 1);
             break;
         case 'development':
             error_reporting(-1);
             ini_set('display_errors', 1);
             break;
         default:
             error_reporting($config->get('error_reporting'));
             ini_set('display_errors', 1);
             break;
     }
     JFactory::$config = $config;
     define('JDEBUG', $config->get('debug', false));
     $container->protect('config', function () use($config) {
         return $config;
     }, true);
 }
开发者ID:houzhenggang,项目名称:cobalt,代码行数:45,代码来源:ConfigServiceProvider.php

示例4: testProtectShared

 /**
  * @testdox The convenience method protect() sets resources as shared when passed true as third arg
  */
 public function testProtectShared()
 {
     $container = new Container();
     $container->protect('foo', function () {
         return new \StdClass();
     }, true);
     $this->assertTrue($container->isShared('foo'));
     $this->assertTrue($container->isProtected('foo'));
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:12,代码来源:ContainerSetupTest.php


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