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

Fix events configuration for Yii Debug #113

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## 6.1.1 under development

- no changes in this release.
- Bug #112: Fix events configuration for Yii Debug (@vjik)

## 6.1.0 May 28, 2024

- New #102: Add layout specific injections (@vjik)
- Enh #107: Implement lazy loading for injections (@vjik)
- Enh #79: Add debug collector for yiisoft/yii-debug (@xepozz)
- Enh #99: Make `viewPath` in `ViewRenderer` constructor optional (@vjik)
- Bug #82: Fixed find for layout file due to compatibility with `yiisoft/view` (@rustamwin)
- Bug #82: Fix find for layout file due to compatibility with `yiisoft/view` (@rustamwin)

## 6.0.0 February 16, 2023

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"maglnet/composer-require-checker": "^4.3",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^9.5",
"rector/rector": "^1.0.0",
"rector/rector": "1.0.*",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.24",
Expand Down
4 changes: 4 additions & 0 deletions config/events-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Yiisoft\View\Event\WebView\AfterRender;
use Yiisoft\Yii\View\Debug\WebViewCollector;

if (!($params['yiisoft/yii-debug']['enabled'] ?? false)) {
return [];
}

return [
AfterRender::class => [
[WebViewCollector::class, 'collect'],
Expand Down
18 changes: 18 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public function testDiWeb(): void
$this->assertInstanceOf(ViewRenderer::class, $viewRenderer);
}

public function testEventsWebWithDebug(): void
{
$eventsConfig = $this->getEventsWeb(['yiisoft/yii-debug' => ['enabled' => true]]);
$this->assertCount(1, $eventsConfig);
}

public function testEventsWebWithoutDebug(): void
{
$eventsConfig = $this->getEventsWeb(['yiisoft/yii-debug' => ['enabled' => false]]);
$this->assertCount(0, $eventsConfig);
}

private function createContainer(?string $postfix = null): Container
{
return new Container(
Expand All @@ -43,6 +55,12 @@ private function getDiConfig(?string $postfix = null): array
return require dirname(__DIR__) . '/config/di' . ($postfix !== null ? '-' . $postfix : '') . '.php';
}

private function getEventsWeb(?array $params = null)
{
$params ??= $this->getParams();
return require dirname(__DIR__) . '/config/events-web.php';
}

private function getParams(): array
{
return require dirname(__DIR__) . '/config/params.php';
Expand Down
Loading