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


PHP Pimple::offsetGet方法代码示例

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


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

示例1: offsetGet

 /**
  * {@inheritdoc}
  */
 public function offsetGet($id)
 {
     if (!in_array($id, $this->serviceWhiteList)) {
         throw new \LogicException(sprintf('You cannot retrieve services until the app has been booted. Attempting to access %s', $id));
     }
     return $this->container->offsetGet($id);
 }
开发者ID:johndotcat,项目名称:bolt,代码行数:10,代码来源:ContainerProxy.php

示例2: it_normalizes_expressions

 public function it_normalizes_expressions($parser, \Pimple $container)
 {
     $container->offsetExists('_normalize')->willReturn(true);
     $container->offsetGet('_normalize')->willReturn(array('foo' => 'bar'));
     $parser->evaluate('foo', array('foo' => 'bar'))->willReturn('bar')->shouldBeCalled();
     $this->normalize('?foo', $container)->shouldReturn('bar');
 }
开发者ID:td7650,项目名称:yml2pimple,代码行数:7,代码来源:ExpressionNormalizerSpec.php

示例3: it_creates_a_array_parameter_and_merges_existing_data

 public function it_creates_a_array_parameter_and_merges_existing_data(Parameter $parameterConf, \Pimple $container)
 {
     $parameterConf->getParameterName()->willReturn('db.options');
     $parameterConf->getParameterValue()->willReturn(array('host' => 'example.org'));
     $parameterConf->getMergeStrategy(Argument::type('array'))->willReturn('array_replace_recursive');
     $parameterConf->mergeExisting()->willReturn(true);
     $container->offsetExists('db.options')->willReturn(true);
     $container->offsetGet('db.options')->willReturn(array('host' => 'localhost', 'user' => 'root', 'password' => 'test'));
     $container->offsetSet('db.options', array('host' => 'example.org', 'user' => 'root', 'password' => 'test'))->shouldBeCalled();
     $container = $this->create($parameterConf, $container);
 }
开发者ID:td7650,项目名称:yml2pimple,代码行数:11,代码来源:ParameterFactorySpec.php

示例4: setup

 /**
  * @param \Pimple $app
  *
  * @throws \Doctrine\DBAL\DBALException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function setup(\Pimple $app)
 {
     if (!$app->offsetExists('config') || !isset($app->offsetGet('config')['doctrine'])) {
         return;
     }
     $config = $app->offsetGet('config');
     ConfigResolver::resolve((array) $config['doctrine:dbal']);
     $app['connections'] = $app::share(function () use($config) {
         $connections = new \Pimple();
         foreach ((array) $config['doctrine:dbal:connections'] as $id => $params) {
             $connections->offsetSet($id, DriverManager::getConnection($params));
         }
         return $connections;
     });
     $app['connection'] = $app::share(function (\Pimple $app) use($config) {
         $ids = $app['connections']->keys();
         $default = $config['doctrine:dbal:default_connection'] ?: current($ids);
         return $app['connections'][$default];
     });
 }
开发者ID:kamilsk,项目名称:kilex,代码行数:29,代码来源:DoctrineServiceProvider.php

示例5: get

 public function get($id)
 {
     try {
         return parent::offsetGet($id);
     } catch (\Exception $e) {
         if (extension_loaded('xdebug')) {
             throw new DiException(sprintf('Service error "%s" in file "%s" on line %d >> "%s".', $id, xdebug_call_file(), xdebug_call_line(), $e->getMessage()));
         } else {
             throw new DiException(sprintf('Service error "%s" >> "%s"', $id, $e->getMessage()));
         }
     }
 }
开发者ID:sirprize,项目名称:scrubble,代码行数:12,代码来源:DiContainer.php

示例6: setup

 /**
  * @param \Pimple $app
  *
  * @throws \InvalidArgumentException
  *
  * @api
  *
  * @quality:method [B]
  */
 public function setup(\Pimple $app)
 {
     if (!$app->offsetExists('config') || !isset($app->offsetGet('config')['monolog'])) {
         return;
     }
     $config = $app->offsetGet('config');
     $app['loggers'] = $app::share(function (\Pimple $app) use($config) {
         return new LoggerLocator((array) $config['monolog'], $app['app.name']);
     });
     $app['logger'] = $app::share(function (\Pimple $app) {
         return $app['loggers']->getDefaultChannel();
     });
     $app['monolog.bridge'] = $app::share(function (\Pimple $app) {
         return function (OutputInterface $output) use($app) {
             if (class_exists('Symfony\\Bridge\\Monolog\\Handler\\ConsoleHandler') && interface_exists('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface')) {
                 $consoleHandler = new ConsoleHandler($output);
                 /** @var \Monolog\Logger $logger */
                 foreach ($app['loggers'] as $logger) {
                     $logger->pushHandler($consoleHandler);
                 }
             }
         };
     });
 }
开发者ID:kamilsk,项目名称:kilex,代码行数:33,代码来源:MonologServiceProvider.php

示例7: offsetGet

 public function offsetGet($id)
 {
     if (!$this->offsetExists($id)) {
         $this[$id] = function ($c) use($id) {
             $arr = array('php', 'ini', 'yml', 'json', 'cache');
             $configDir = $c['configDir']();
             foreach ($arr as $v) {
                 $file = $configDir . "/" . $id . "." . $v;
                 if (file_exists($file)) {
                     break;
                 } else {
                     $file = null;
                 }
             }
             \Fobia\Debug\Log::debug(">> autoload config", array($id, $file));
             if (!$file) {
                 trigger_error("Нет автозагрузочной секции конфигурации '{$id}'" . "/{$file}", E_USER_ERROR);
                 return;
             }
             return Utils::loadConfig($file);
         };
     }
     return parent::offsetGet($id);
 }
开发者ID:fobiaweb,项目名称:base,代码行数:24,代码来源:AutoloadConfig.php

示例8: offsetGet

 /**
  * @inheritdoc
  */
 public function offsetGet($id)
 {
     $value = parent::offsetGet($id);
     return is_string($value) ? $this->resolveString($value) : $value;
 }
开发者ID:zroger,项目名称:feather,代码行数:8,代码来源:Feather.php

示例9: it_can_normalize_array_access_style

 public function it_can_normalize_array_access_style(\Pimple $container)
 {
     $container->offsetExists('foo')->willReturn(true);
     $container->offsetGet('foo')->willReturn(array('bar' => 'Hello World'));
     $this->normalize('%foo..bar%', $container)->shouldBe('Hello World');
 }
开发者ID:td7650,项目名称:yml2pimple,代码行数:6,代码来源:PimpleNormalizerSpec.php

示例10: __invoke

 public function __invoke()
 {
     return $this->pimple->offsetGet($this->serviceId);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:4,代码来源:LazyLocator.php

示例11:

 function it_delegates_get(\Pimple $pimple)
 {
     $pimple->offsetGet('foo')->shouldBeCalled();
     $this->get('foo');
 }
开发者ID:netzmacht,项目名称:contao-toolkit,代码行数:5,代码来源:PimpleAdapterSpec.php

示例12: get

 /**
  * Gets a service by id.
  *
  * @param string $id The service id
  *
  * @return object The service
  */
 public static function get($id)
 {
     return self::$pimple->offsetGet($id);
 }
开发者ID:bangpound,项目名称:drupal-service-provider,代码行数:11,代码来源:Druplex.php

示例13: offsetGet

 /**
  * Gets a parameter or an object, first from Pimple, then from the fallback container if it is set.
  *
  * @param string $id The unique identifier for the parameter or object
  *
  * @return mixed The value of the parameter or an object
  *
  * @throws PimpleNotFoundException if the identifier is not defined
  */
 public function offsetGet($id)
 {
     if (!$this->fallbackContainer || $this->mode == self::MODE_STANDARD_COMPLIANT) {
         try {
             return parent::offsetGet($id);
         } catch (\InvalidArgumentException $e) {
             // To respect container-interop, let's wrap the exception.
             throw new PimpleNotFoundException($e->getMessage(), $e->getCode(), $e);
         }
     } elseif ($this->mode == self::MODE_ACT_AS_MASTER) {
         if ($this->nbLoops != 0) {
             if (!array_key_exists($id, $this->values)) {
                 throw new PimpleNotFoundException(sprintf('Identifier "%s" is not defined.', $id));
             }
             $isFactory = is_object($this->values[$id]) && method_exists($this->values[$id], '__invoke');
             return $isFactory ? $this->values[$id]($this->wrappedFallbackContainer) : $this->values[$id];
         } else {
             $this->nbLoops++;
             $instance = $this->fallbackContainer->get($id);
             $this->nbLoops--;
             return $instance;
         }
     } else {
         throw new \Exception("Invalid mode set");
     }
 }
开发者ID:bangpound,项目名称:pimple-interop,代码行数:35,代码来源:PimpleInterop.php

示例14: setParameter

 /**
  * Sets a parameter.
  *
  * @param string $name  The parameter name
  * @param mixed  $value The parameter value
  *
  * @api
  */
 public function setParameter($name, $value)
 {
     $config = $this->pimple->offsetGet('config');
     $config[$name] = $value;
     $this->pimple->offsetSet('config', $config);
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:14,代码来源:Container.php

示例15: offsetGet

 public function offsetGet($id)
 {
     $this->assertSetUpHasBeenCalled();
     return parent::offsetGet($id);
 }
开发者ID:matthiasnoback,项目名称:phpunit-test-service-container,代码行数:5,代码来源:ServiceContainer.php


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