Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slim4 #49

Merged
merged 10 commits into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"php": "~7.1",
"php-di/php-di": "^6.0.0",
"php-di/invoker": "^2.0.0",
"slim/slim": "^4.0.0"
"slim/slim": "^4.2.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0",
Expand Down
3 changes: 1 addition & 2 deletions src/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ public static function create(ContainerInterface $container = null): App
{
$container = $container ?: new Container;

AppFactory::setContainer($container);
$callableResolver = new InvokerCallableResolver($container);
AppFactory::setCallableResolver(new CallableResolver($callableResolver));

$app = AppFactory::create();
$app = AppFactory::createFromContainer($container);

$controllerInvoker = self::createControllerInvoker($container);
$app->getRouteCollector()->setDefaultInvocationStrategy($controllerInvoker);
Expand Down
2 changes: 1 addition & 1 deletion tests/RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function injects_route_placeholder_over_request_attribute()
public function resolve_controller_from_container()
{
$app = Bridge::create();
$app->get('/', [UserController::class, 'dashboard']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This is a regression here, this shouldn't be changed.

This is because AppFactory::createFromContainer($container) doesn't work like the old method. AppFactory::setCallableResolver(new CallableResolver($callableResolver)); should be removed, and instead the callable resolver should be defined in the container.

Copy link
Contributor Author

@fritsvt fritsvt Sep 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I updated the PR.

$app->get('/', UserController::class . ':dashboard');

$response = $app->handle(RequestFactory::create());
$this->assertEquals('Hello world!', (string) $response->getBody());
Expand Down