Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 89ab38d

Browse files
committed
Allow usage of ResponseInterface services that return a factory
Expressive 2.2 returns a factory instead of an instance; this allows you to us that factory to generate the instance.
1 parent 6d16330 commit 89ab38d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/ResponsePrototypeTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ protected function getResponsePrototype(ContainerInterface $container) : Respons
2929
ResponseInterface::class
3030
));
3131
}
32-
return $container->has(ResponseInterface::class)
32+
33+
$response = $container->has(ResponseInterface::class)
3334
? $container->get(ResponseInterface::class)
3435
: new Response();
36+
37+
// Allow usage of callable factories to generate a response.
38+
return is_callable($response) ? $response() : $response;
3539
}
3640
}

0 commit comments

Comments
 (0)