Commit 6543379c authored by Marijn Huizendveld's avatar Marijn Huizendveld

Allow constructor arguments.

parent 0829298b
...@@ -52,10 +52,16 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte ...@@ -52,10 +52,16 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
private $booted = false; private $booted = false;
/** /**
* Constructor. * Instantiate a new Application.
*
* Objects and parameters can be passed as argument to the constructor.
*
* @param array $values The parameters or objects.
*/ */
public function __construct() public function __construct(array $values = array())
{ {
parent::__construct($values);
$app = $this; $app = $this;
$this['logger'] = null; $this['logger'] = null;
......
...@@ -48,6 +48,14 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase ...@@ -48,6 +48,14 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Silex\Controller', $returnValue); $this->assertInstanceOf('Silex\Controller', $returnValue);
} }
public function testConstructorInjection ()
{
$params = array("param" => "value");
$app = new Application($params);
$this->assertSame($params['param'], $app['param']);
}
public function testGetRequest() public function testGetRequest()
{ {
$request = Request::create('/'); $request = Request::create('/');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment