Skip to content

Commit 4dfe16f

Browse files
committed
Merge pull request #5 from jdreesen/controller-resolver-as-shared-service
Override ControllerResolver as a shared service
2 parents b527077 + 0d6cb77 commit 4dfe16f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Application.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public function __construct(ContainerBuilder $containerBuilder = null, array $va
4343
parent::__construct($values);
4444

4545
// Override the controller resolver with ours
46-
$this['resolver'] = new ControllerResolver($this->phpdi);
46+
$this['resolver'] = $this->share(function () {
47+
return new ControllerResolver($this->phpdi);
48+
});
4749
}
4850

4951
public function offsetGet($id)

tests/ApplicationTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,15 @@ public function the_application_should_expose_phpdi_container()
4242

4343
$this->assertInstanceOf('DI\Container', $app->getPhpDi());
4444
}
45+
46+
/**
47+
* @test
48+
*/
49+
public function the_controller_resolver_should_be_registered_as_a_service()
50+
{
51+
$app = new Application();
52+
53+
$this->assertInstanceOf('Closure', $app->raw('resolver'));
54+
$this->assertInstanceOf('DI\Bridge\Silex\Controller\ControllerResolver', $app['resolver']);
55+
}
4556
}

0 commit comments

Comments
 (0)