diff --git a/blog-api/config/common/di/router.php b/blog-api/config/common/di/router.php index 23eef381..ef863167 100644 --- a/blog-api/config/common/di/router.php +++ b/blog-api/config/common/di/router.php @@ -6,12 +6,17 @@ use Yiisoft\Config\Config; use Yiisoft\DataResponse\Middleware\FormatDataResponse; use Yiisoft\Request\Body\RequestBodyParser; +use Yiisoft\Router\FastRoute\UrlGenerator; use Yiisoft\Router\Group; use Yiisoft\Router\RouteCollection; use Yiisoft\Router\RouteCollectionInterface; use Yiisoft\Router\RouteCollectorInterface; +use Yiisoft\Router\UrlGeneratorInterface; -/** @var Config $config */ +/** + * @var Config $config + * @var array $params + */ return [ RouteCollectionInterface::class => static function (RouteCollectorInterface $collector) use ($config) { @@ -21,9 +26,17 @@ ->middleware(RequestBodyParser::class) ->addGroup( Group::create('/{_language}') - ->routes(...$config->get('routes')) + ->routes(...$config->get('routes')) ); return new RouteCollection($collector); }, + UrlGeneratorInterface::class => [ + 'class' => UrlGenerator::class, + 'setEncodeRaw()' => [$params['yiisoft/router-fastroute']['encodeRaw']], + 'setDefaultArgument()' => ['_language', 'en'], + 'reset' => function () { + $this->defaultArguments = []; + }, + ], ];