Skip to content

Commit

Permalink
Split routes
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Oct 5, 2023
1 parent 009e31e commit 1581c09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions blog/config/common/di/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@
use Yiisoft\Router\RouteCollectorInterface;
use Yiisoft\Yii\Debug\Viewer\Middleware\ToolbarMiddleware;

/** @var Config $config */
/**
* @var Config $config
* @var array $params
*/

return [
RouteCollectionInterface::class => static function (RouteCollectorInterface $collector) use ($config) {
$collector
->middleware(CsrfMiddleware::class)
->middleware(FormatDataResponse::class)
->addGroup(
Group::create('/{_language}')
Group::create()
->routes(...$config->get('routes'))
)
->addGroup(
Group::create('/{_language}')
->routes(...$config->get('app-routes'))
);

if (!str_starts_with(getenv('YII_ENV') ?: '', 'prod')) {
Expand Down
2 changes: 1 addition & 1 deletion blog/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'$events',
'console/events.php',
],
'routes' => [
'app-routes' => [
'common/routes/*.php',
],
'bootstrap' => [
Expand Down

0 comments on commit 1581c09

Please sign in to comment.