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


PHP Container::raw方法代码示例

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


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

示例1: register

 public function register(Container $app)
 {
     $app['logger'] = function () use($app) {
         return $app['monolog'];
     };
     if ($bridge = class_exists('Symfony\\Bridge\\Monolog\\Logger')) {
         $app['monolog.handler.debug'] = function () use($app) {
             $level = MonologServiceProvider::translateLevel($app['monolog.level']);
             return new DebugHandler($level);
         };
         if (isset($app['request_stack'])) {
             $app['monolog.not_found_activation_strategy'] = function () use($app) {
                 return new NotFoundActivationStrategy($app['request_stack'], array('^/'), $app['monolog.level']);
             };
         }
     }
     $app['monolog.logger.class'] = $bridge ? 'Symfony\\Bridge\\Monolog\\Logger' : 'Monolog\\Logger';
     $app['monolog'] = function ($app) {
         $log = new $app['monolog.logger.class']($app['monolog.name']);
         $handler = new Handler\GroupHandler($app['monolog.handlers']);
         if (isset($app['monolog.not_found_activation_strategy'])) {
             $handler = new Handler\FingersCrossedHandler($handler, $app['monolog.not_found_activation_strategy']);
         }
         $log->pushHandler($handler);
         if ($app['debug'] && isset($app['monolog.handler.debug'])) {
             $log->pushHandler($app['monolog.handler.debug']);
         }
         return $log;
     };
     $app['monolog.formatter'] = function () {
         return new LineFormatter();
     };
     $app['monolog.handler'] = $defaultHandler = function () use($app) {
         $level = MonologServiceProvider::translateLevel($app['monolog.level']);
         $handler = new Handler\StreamHandler($app['monolog.logfile'], $level, $app['monolog.bubble'], $app['monolog.permission']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $app['monolog.handlers'] = function () use($app, $defaultHandler) {
         $handlers = array();
         // enables the default handler if a logfile was set or the monolog.handler service was redefined
         if ($app['monolog.logfile'] || $defaultHandler !== $app->raw('monolog.handler')) {
             $handlers[] = $app['monolog.handler'];
         }
         return $handlers;
     };
     $app['monolog.level'] = function () {
         return Logger::DEBUG;
     };
     $app['monolog.listener'] = function () use($app) {
         return new LogListener($app['logger'], $app['monolog.exception.logger_filter']);
     };
     $app['monolog.name'] = 'app';
     $app['monolog.bubble'] = true;
     $app['monolog.permission'] = null;
     $app['monolog.exception.logger_filter'] = null;
     $app['monolog.logfile'] = null;
     $app['monolog.use_error_handler'] = !$app['debug'];
 }
开发者ID:abdonor,项目名称:silex_simple_api,代码行数:59,代码来源:MonologServiceProvider.php

示例2: register

 /**
  * {@inheritDoc}
  */
 public function register(Container $container)
 {
     $container['defaultErrorHandler'] = $container->raw('phpErrorHandler');
     $container['errorHandler'] = function ($container) {
         return new ErrorHandler($container);
     };
     $container['phpErrorHandler'] = function ($container) {
         return new ErrorHandler($container);
     };
 }
开发者ID:ansas,项目名称:php-component,代码行数:13,代码来源:ErrorProvider.php

示例3: register

 /**
  * {@inheritDoc}
  */
 public function register(Container $container)
 {
     // Save default handler under new name
     $container['defaultNotAllowedHandler'] = $container->raw('notAllowedHandler');
     /**
      * Add dependency (DI).
      *
      * @param Container $c
      *
      * @return NotAllowedHandler
      */
     $container['notAllowedHandler'] = function ($c) {
         return new NotAllowedHandler($c);
     };
 }
开发者ID:ansas,项目名称:php-component,代码行数:18,代码来源:NotAllowedProvider.php

示例4: testConstructor

 /**
  * Test __construct().
  */
 public function testConstructor()
 {
     $app = new Application(['foo' => 'bar']);
     $this->assertInstanceOf(Config::class, $app['config']);
     $providers = $app->getProviders();
     foreach ($providers as $provider) {
         $container = new Container();
         $container->register(new $provider());
         $container['config'] = $app->raw('config');
         $container['access_token'] = $app->raw('access_token');
         $container['request'] = $app->raw('request');
         $container['cache'] = $app->raw('cache');
         foreach ($container->keys() as $providerName) {
             $this->assertEquals($container->raw($providerName), $app->raw($providerName));
         }
         unset($container);
     }
 }
开发者ID:edtim8,项目名称:wechat,代码行数:21,代码来源:ApplicationTest.php

示例5: raw

 public function raw($id)
 {
     return $this->pimpleContainer->raw($this->ensureNamespacesLoaded($id));
 }
开发者ID:zwilias,项目名称:dimple,代码行数:4,代码来源:Container.php

示例6: testRawValidatesKeyIsPresent

 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Identifier "foo" is not defined.
  */
 public function testRawValidatesKeyIsPresent()
 {
     $pimple = new Container();
     $pimple->raw('foo');
 }
开发者ID:pancke,项目名称:yyaf,代码行数:9,代码来源:PimpleTest.php

示例7: register

 /**
  * {@inheritDoc}
  */
 public function register(PimpleContainer $slimContainer)
 {
     foreach ($this->pimpleContainer->keys() as $key) {
         $slimContainer[$key] = $this->pimpleContainer->raw($key);
     }
 }
开发者ID:geggleto,项目名称:slim-pimple-bridge,代码行数:9,代码来源:SlimPimpleBridge.php


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