Skip to content

Commit

Permalink
Merge pull request #5 from jdreesen/controller-resolver-as-shared-ser…
Browse files Browse the repository at this point in the history
…vice

Override ControllerResolver as a shared service
  • Loading branch information
mnapoli committed Sep 2, 2015
2 parents b527077 + 0d6cb77 commit 4dfe16f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function __construct(ContainerBuilder $containerBuilder = null, array $va
parent::__construct($values);

// Override the controller resolver with ours
$this['resolver'] = new ControllerResolver($this->phpdi);
$this['resolver'] = $this->share(function () {
return new ControllerResolver($this->phpdi);
});
}

public function offsetGet($id)
Expand Down
11 changes: 11 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ public function the_application_should_expose_phpdi_container()

$this->assertInstanceOf('DI\Container', $app->getPhpDi());
}

/**
* @test
*/
public function the_controller_resolver_should_be_registered_as_a_service()
{
$app = new Application();

$this->assertInstanceOf('Closure', $app->raw('resolver'));
$this->assertInstanceOf('DI\Bridge\Silex\Controller\ControllerResolver', $app['resolver']);
}
}

0 comments on commit 4dfe16f

Please sign in to comment.