コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * @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];
     });
 }
コード例 #3
0
 /**
  * @param Pimple $pimple
  */
 function it_adds_parameters_on_pimple($pimple, $loader)
 {
     $pimple->offsetSet('hello', 'world')->shouldBeCalled();
     $loader->load('config.json')->willReturn(array('hello' => 'world'));
     $this->configure($pimple, 'config.json');
 }
コード例 #4
0
ファイル: ContainerProxy.php プロジェクト: johndotcat/bolt
 /**
  * {@inheritdoc}
  */
 public function offsetSet($id, $value)
 {
     $this->container->offsetSet($id, $value);
 }
コード例 #5
0
 /**
  * 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);
 }