@@ -79,64 +79,64 @@ If you want to version by Accept header, you will need to do the following:
7979
8080#. The format listener must be enabled
8181
82- See :doc: `Format Listener <format_listener >`
82+ See :doc: `Format Listener <format_listener >`
8383
8484#. The client must pass the requested version in his header like this :
8585
86- .. code-block :: yaml
86+ .. code-block :: yaml
8787
88- Accept:application/json;version=1.0
88+ Accept:application/json;version=1.0
8989
9090 #. You must configure the possible mime types for all supported versions:
9191
92- .. code-block :: yaml
93-
94- fos_rest :
95- view :
96- mime_types :
97- json : ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']
98-
99- Note: If you have to handle huge versions and mime types, you can simplify the configuration with a php script:
100-
101- .. code-block :: php
102-
103- // app/config/fos_rest_mime_types.php
104- $versions = array(
105- '1.0',
106- '1.1',
107- '2.0',
108- );
109-
110- $mimeTypes = array(
111- 'json' => array(
112- 'application/json',
113- ),
114- 'yml' => array(
115- 'application/yaml',
116- 'text/yaml',
117- ),
118- );
119-
120- array_walk($mimeTypes, function (& $mimeTypes, $format, $versions) {
121- $versionMimeTypes = array();
122- foreach ($mimeTypes as $mimeType) {
123- foreach ($versions as $version) {
124- array_push($versionMimeTypes, sprintf('%s;version=%s', $mimeType, $version));
125- array_push($versionMimeTypes, sprintf('%s;v=%s', $mimeType, $version));
126- }
127- }
128- $mimeTypes = array_merge($mimeTypes, $versionMimeTypes);
129- }, $versions);
130-
131- $container->loadFromExtension('fos_rest', array(
132- 'view' => array(
133- 'mime_types' => $mimeTypes,
134- ),
135- ));
136-
137- And then, import it from your config.yml file:
138-
139- .. code-block :: yaml
92+ .. code-block :: yaml
93+
94+ fos_rest :
95+ view :
96+ mime_types :
97+ json : ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']
98+
99+ Note: If you have to handle huge versions and mime types, you can simplify the configuration with a php script:
100+
101+ .. code-block :: php
102+
103+ // app/config/fos_rest_mime_types.php
104+ $versions = array(
105+ '1.0',
106+ '1.1',
107+ '2.0',
108+ );
109+
110+ $mimeTypes = array(
111+ 'json' => array(
112+ 'application/json',
113+ ),
114+ 'yml' => array(
115+ 'application/yaml',
116+ 'text/yaml',
117+ ),
118+ );
119+
120+ array_walk($mimeTypes, function (& $mimeTypes, $format, $versions) {
121+ $versionMimeTypes = array();
122+ foreach ($mimeTypes as $mimeType) {
123+ foreach ($versions as $version) {
124+ array_push($versionMimeTypes, sprintf('%s;version=%s', $mimeType, $version));
125+ array_push($versionMimeTypes, sprintf('%s;v=%s', $mimeType, $version));
126+ }
127+ }
128+ $mimeTypes = array_merge($mimeTypes, $versionMimeTypes);
129+ }, $versions);
130+
131+ $container->loadFromExtension('fos_rest', array(
132+ 'view' => array(
133+ 'mime_types' => $mimeTypes,
134+ ),
135+ ));
136+
137+ And then, import it from your config.yml file:
138+
139+ .. code-block :: yaml
140140
141141 imports :
142142 - { resource: assets_version.php }
0 commit comments