本文整理汇总了PHP中Pimple::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimple::offsetSet方法的具体用法?PHP Pimple::offsetSet怎么用?PHP Pimple::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimple
的用法示例。
在下文中一共展示了Pimple::offsetSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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];
});
}
示例3:
/**
* @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: offsetSet
/**
* {@inheritdoc}
*/
public function offsetSet($id, $value)
{
$this->container->offsetSet($id, $value);
}
示例5: 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);
}