當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pimple::offsetExists方法代碼示例

本文整理匯總了PHP中Pimple::offsetExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pimple::offsetExists方法的具體用法?PHP Pimple::offsetExists怎麽用?PHP Pimple::offsetExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimple的用法示例。


在下文中一共展示了Pimple::offsetExists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get

 /**
  * Get service from DI container
  *
  * @param $name
  * @return mixed
  * @throws \OutOfBoundsException
  */
 public function get($name)
 {
     if (!$this->container->offsetExists($name)) {
         throw new OutOfBoundsException('Service - "' . $name . '" doesn\'t esist.');
     }
     return $this->container[$name];
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:14,代碼來源:PimpleContainer.php

示例2: handle

 /**
  * @param \Exception $e
  */
 public function handle(\Exception $e)
 {
     $code = $e->getCode();
     // if there is no handler for this do nothing
     if (!$this->_handlers->offsetExists($code)) {
         return;
     }
     return $this->_handlers[$code]($e);
 }
開發者ID:letsface,項目名稱:php-error-handler,代碼行數:12,代碼來源:ExceptionHandler.php

示例3: 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

示例4: 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

示例5: offsetExists

 /**
  * Checks if a parameter or an object is set.
  *
  * @param string $id The unique identifier for the parameter or object
  *
  * @return Boolean
  */
 public function offsetExists($id)
 {
     if (!$this->fallbackContainer || $this->mode == self::MODE_STANDARD_COMPLIANT) {
         return parent::offsetExists($id);
     } elseif ($this->mode == self::MODE_ACT_AS_MASTER) {
         if ($this->nbLoops != 0) {
             return parent::offsetExists($id);
         } else {
             $this->nbLoops++;
             $has = $this->fallbackContainer->has($id);
             $this->nbLoops--;
             return $has;
         }
     } else {
         throw new \Exception("Invalid mode set");
     }
 }
開發者ID:bangpound,項目名稱:pimple-interop,代碼行數:24,代碼來源:PimpleInterop.php

示例6: 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

示例7: 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

示例8: offsetExists

 /**
  * {@inheritdoc}
  */
 public function offsetExists($id)
 {
     return $this->container->offsetExists($id);
 }
開發者ID:johndotcat,項目名稱:bolt,代碼行數:7,代碼來源:ContainerProxy.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:

 function it_delegates_has(\Pimple $pimple)
 {
     $pimple->offsetExists('foo')->shouldBeCalled();
     $this->has('foo');
 }
開發者ID:netzmacht,項目名稱:contao-toolkit,代碼行數:5,代碼來源:PimpleAdapterSpec.php

示例11: has

 /**
  * Returns true if the service id is defined.
  *
  * @param string $id The service id
  *
  * @return Boolean true if the service id is defined, false otherwise
  */
 public static function has($id)
 {
     return self::$pimple->offsetExists($id);
 }
開發者ID:bangpound,項目名稱:drupal-service-provider,代碼行數:11,代碼來源:Druplex.php

示例12: let

 /**
  * @param Pimple $pimple
  */
 function let($pimple)
 {
     $pimple->offsetExists(Argument::any())->willReturn(true);
     $this->beConstructedWith($pimple);
 }
開發者ID:ilosada,項目名稱:chamilo-lms-icpna,代碼行數:8,代碼來源:PimpleNormalizerSpec.php

示例13: has

 public function has($id)
 {
     return parent::offsetExists($id);
 }
開發者ID:sirprize,項目名稱:scrubble,代碼行數:4,代碼來源:DiContainer.php

示例14: has

 /**
  * Returns true if the given service is defined.
  *
  * @param string $id The service identifier
  *
  * @return Boolean true if the service is defined, false otherwise
  *
  * @api
  */
 public function has($id)
 {
     return $this->pimple->offsetExists($id);
 }
開發者ID:ClaudioThomas,項目名稱:shopware-4,代碼行數:13,代碼來源:Container.php

示例15: offsetExists

 public function offsetExists($id)
 {
     $this->assertSetUpHasBeenCalled();
     return parent::offsetExists($id);
 }
開發者ID:matthiasnoback,項目名稱:phpunit-test-service-container,代碼行數:5,代碼來源:ServiceContainer.php


注:本文中的Pimple::offsetExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。