Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions blog-api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"cycle/entity-behavior": "^1.0",
"cycle/orm": "^2.0",
"doctrine/collections": "^2.0",
"friendsofphp/proxy-manager-lts": "^1.0",
"httpsoft/http-message": "^1.1",
"myclabs/php-enum": "^1.7",
"psr/container": "^1.0|^2.0",
Expand All @@ -43,8 +44,8 @@
"yiisoft/config": "^1.0",
"yiisoft/data": "^1.0",
"yiisoft/data-response": "^2.0",
"yiisoft/definitions": "^3.0",
"yiisoft/di": "^1.0",
"yiisoft/definitions": "dev-lazy-definition as 3.0.1",
"yiisoft/di": "dev-lazy-services as 1.2.0",
"yiisoft/error-handler": "^3.0",
"yiisoft/factory": "^1.0",
"yiisoft/files": "^2.0",
Expand Down
3 changes: 3 additions & 0 deletions blog-api/config/web/di/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
/** @var array $params */

return [
\App\VersionProvider::class => [
'lazy' => true,
],
Yiisoft\Yii\Http\Application::class => [
'__construct()' => [
'dispatcher' => DynamicReference::to(static function (Injector $injector) use ($params) {
Expand Down
6 changes: 5 additions & 1 deletion blog-api/src/InfoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function __construct(private VersionProvider $versionProvider)
*/
public function index(DataResponseFactoryInterface $responseFactory): ResponseInterface
{
return $responseFactory->createResponse(['version' => $this->versionProvider->version, 'author' => 'yiisoft']);
return $responseFactory->createResponse([
'version' => $this->versionProvider->version,
'lazy' => $this->versionProvider instanceof \ProxyManager\Proxy\LazyLoadingInterface,
'author' => 'yiisoft',
]);
}
}
1 change: 1 addition & 0 deletions blog-api/tests/Acceptance/SiteCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function getHome(AcceptanceTester $I): void
'error_code' => null,
'data' => [
'version' => '3.0',
'lazy' => true,
'author' => 'yiisoft',
],
]
Expand Down
12 changes: 10 additions & 2 deletions blog-api/tests/Functional/IndexControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public function testGetIndex(): void
'status' => 'success',
'error_message' => '',
'error_code' => null,
'data' => ['version' => '3.0', 'author' => 'yiisoft'],
'data' => [
'version' => '3.0',
'author' => 'yiisoft',
'lazy' => true,
],
],
$response->getContentAsJson()
);
Expand All @@ -52,7 +56,11 @@ public function testGetIndexMockVersion(): void
'status' => 'success',
'error_message' => '',
'error_code' => null,
'data' => ['version' => '3.0.0', 'author' => 'yiisoft'],
'data' => [
'version' => '3.0.0',
'author' => 'yiisoft',
'lazy' => false,
],
],
$response->getContentAsJson()
);
Expand Down