Skip to content

Commit 7f97f3e

Browse files
authored
Move formatters to params (#60)
1 parent 45937cb commit 7f97f3e

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"source-directory": "config"
4949
},
5050
"config-plugin": {
51+
"params": "params.php",
5152
"web": "web.php"
5253
}
5354
},

config/params.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter;
6+
use Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter;
7+
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
8+
9+
return [
10+
'yiisoft/data-response' => [
11+
'contentFormatters' => [
12+
'text/html' => HtmlDataResponseFormatter::class,
13+
'application/xml' => XmlDataResponseFormatter::class,
14+
'application/json' => JsonDataResponseFormatter::class,
15+
],
16+
],
17+
];

config/web.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
use Yiisoft\DataResponse\DataResponseFactoryInterface;
77
use Yiisoft\DataResponse\DataResponseFormatterInterface;
88
use Yiisoft\DataResponse\Formatter\HtmlDataResponseFormatter;
9-
use Yiisoft\DataResponse\Formatter\XmlDataResponseFormatter;
10-
use Yiisoft\DataResponse\Formatter\JsonDataResponseFormatter;
119
use Yiisoft\DataResponse\Middleware\ContentNegotiator;
10+
use Yiisoft\Di\DynamicReferencesArray;
1211

1312
/* @var $params array */
1413

@@ -17,11 +16,7 @@
1716
DataResponseFactoryInterface::class => DataResponseFactory::class,
1817
ContentNegotiator::class => [
1918
'__construct()' => [
20-
'contentFormatters' => [
21-
'text/html' => new HtmlDataResponseFormatter(),
22-
'application/xml' => new XmlDataResponseFormatter(),
23-
'application/json' => new JsonDataResponseFormatter(),
24-
],
19+
'contentFormatters' => DynamicReferencesArray::from($params['yiisoft/data-response']['contentFormatters']),
2520
],
2621
],
2722
];

0 commit comments

Comments
 (0)