Skip to content

Commit

Permalink
Add debug toolbar (#319)
Browse files Browse the repository at this point in the history
* Add debug toolbar

* Add view parameters

* Apply fixes from StyleCI

* Update config/common/di/router.php

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
  • Loading branch information
3 people authored Jun 10, 2024
1 parent f978ea8 commit 8a581db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/common/di/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Router\RouteCollection;
use Yiisoft\Router\RouteCollectionInterface;
use Yiisoft\Router\RouteCollectorInterface;
use Yiisoft\Yii\Debug\Viewer\Middleware\ToolbarMiddleware;

/** @var Config $config */

Expand All @@ -22,6 +23,10 @@
->routes(...$config->get('routes'))
);

if (!str_starts_with(getenv('YII_ENV') ?: '', 'prod')) {
$collector->prependMiddleware(ToolbarMiddleware::class);
}

return new RouteCollection($collector);
},
];
14 changes: 14 additions & 0 deletions config/common/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
use App\ViewInjection\CommonViewInjection;
use App\ViewInjection\LayoutViewInjection;
use App\ViewInjection\TranslatorViewInjection;
use Yiisoft\Assets\AssetManager;
use Yiisoft\Definitions\Reference;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Router\UrlGeneratorInterface;
use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\Yii\View\CsrfViewInjection;

return [
Expand All @@ -25,6 +29,16 @@
'defaultCategory' => 'app',
],

'yiisoft/view' => [
'basePath' => '@views',
'parameters' => [
'assetManager' => Reference::to(AssetManager::class),
'urlGenerator' => Reference::to(UrlGeneratorInterface::class),
'currentRoute' => Reference::to(CurrentRoute::class),
'translator' => Reference::to(TranslatorInterface::class),
],
],

'yiisoft/yii-view' => [
'injections' => [
Reference::to(CommonViewInjection::class),
Expand Down

0 comments on commit 8a581db

Please sign in to comment.