merged branch Seldaek/parambag (PR #4220)
Commits
-------
3d9990a
[DependencyInjection] Add ParameterBag::remove
Discussion
----------
[DependencyInjection] Add ParameterBag::remove
This commit is contained in:
commit
1dd92b6221
@ -126,6 +126,18 @@ class ParameterBag implements ParameterBagInterface
|
||||
return array_key_exists(strtolower($name), $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a parameter.
|
||||
*
|
||||
* @param string $key The key
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function remove($key)
|
||||
{
|
||||
unset($this->parameters[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces parameter placeholders (%name%) by their values for all parameters.
|
||||
*/
|
||||
|
@ -43,6 +43,19 @@ class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(), $bag->all(), '->clear() removes all parameters');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::remove
|
||||
*/
|
||||
public function testRemove()
|
||||
{
|
||||
$bag = new ParameterBag(array(
|
||||
'foo' => 'foo',
|
||||
'bar' => 'bar',
|
||||
));
|
||||
$bag->remove('foo');
|
||||
$this->assertEquals(array('bar' => 'bar'), $bag->all(), '->remove() removes a parameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::get
|
||||
* @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::set
|
||||
|
Reference in New Issue
Block a user