Skip to content

Commit dc67616

Browse files
committed
Merge branch '1.8' into 2.0
2 parents f4ce3e9 + 932639b commit dc67616

File tree

14 files changed

+229
-76
lines changed

14 files changed

+229
-76
lines changed

CHANGELOG.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
CHANGELOG
2+
=========
3+
4+
1.8.0
5+
-----
6+
7+
* deprecated the `RedirectView` and `RouteRedirectView` classes, use `View::createRedirect()` and
8+
`View::createRouteRedirect()` instead
9+
10+
* added a `fos_rest.exception.debug` config option that defaults to the `kernel.debug` container
11+
parameter and can be turned on to include the caught exception message in the exception controller's
12+
response
13+
14+
* introduced the concept of REST zones which makes it possible to disable all REST listeners
15+
when a request matches certain attributes
16+
17+
* fixed that serialization groups are always passed to the constructor as an array
18+
19+
* added annotations to support additional HTTP methods defined by RFC 2518 (WebDAV)
20+
21+
* added a new loader that allows to extract REST routes from all controller classes from a
22+
directory
23+
24+
* introduced a serializer adapter layer to ease the integration of custom serialization
25+
implementations
26+
27+
* deprecated the getter methods of the `ViewHandler` class
28+
29+
* fixed an issue that prevented decoration of the `TemplateReferenceInterface` from the Symfony
30+
Templating component
31+
32+
* fixed: no longer overwrite an explicitly configured template in the view response listener
33+
34+
* added support for API versioning in URL parameters, the `Accept` header or using a custom header
35+
36+
* marked some classes and methods as internal, do no longer use them in your code as they are likely
37+
to be removed in future releases
38+
39+
* deprecated the `DoctrineInflector` class and the `InflectorInterface` from the
40+
`FOS\RestBundle\Util\Inflector`in favor of their replacements in the `FOS\RestBundle\Inflector`
41+
namespace
42+
43+
* deprecated the `FormatNegotiator` class and the `FormatNegotiatorInterface` from the
44+
`FOS\RestBundle\Util` namespace in favor of the new `FOS\RestBundle\Negotiation\FormatNegotiator`
45+
class
46+
47+
* deprecated the `FOS\RestBundle\Util\MediaTypeNegotiatorInterface` which should no longer be used
48+
49+
1.7.9
50+
-----
51+
52+
* fixed a BC break that prevented the `CamelKeysNormalizer` from removing leading underscores
53+
54+
* fixed the `AllowedMethodsRouteLoader` to work with Symfony 3.0
55+
56+
1.7.8
57+
-----
58+
59+
* removed uses of the reflection API in favor of faster solutions when possible
60+
61+
* fixed the configuration to use serialization groups and versions at the same time
62+
63+
1.7.7
64+
-----
65+
66+
* when using Symfony 3.x, the bundle doesn't call methods anymore that have been deprecated in
67+
Symfony 2.x and were removed in Symfony 3.0
68+
69+
* the `ViewResponseListener` does not overwrite explicitly configured templates anymore
70+
71+
* fixed the `ParamFetcher` class to properly handle sub requests
72+
73+
1.7.6
74+
-----
75+
76+
* added a `CamelKeysNormalizerWithLeadingUnderscore` that keeps leading underscores when
77+
converting snake case to camel case (for example, leaving `_username` unchanged)
78+
79+
1.7.5
80+
-----
81+
82+
**CAUTION:** Accidentally, this patch release was never published.
83+
84+
1.7.4
85+
-----
86+
87+
* removed some code from the `ViewResponseListener` class that was already present in the parent
88+
`TemplateListener` class
89+
90+
1.7.3
91+
-----
92+
93+
* made it possible to use the bundle with Symfony 3.x and fixed some compatibility issues with
94+
Symfony 3.0
95+
96+
* fixed the exception controller to return a 406 (Not Acceptable) response when the format
97+
negotiator throws an exception
98+
99+
1.7.2
100+
-----
101+
102+
* fixed loading XML schema definition files in case the paths contain special characters (like
103+
spaces)
104+
105+
* return the FQCN in the form type extension's `getExtendedType()` method to be compatible with
106+
Symfony >= 2.8
107+
108+
* added the `extended-type` attribute to the `form.type_extension` tag to be compatible with
109+
Symfony >= 2.8
110+
111+
* fixed some code examples in the documentation
112+
113+
* fixed exception message when using non-numeric identifiers (like UUID or GUID)
114+
115+
* allow version 1.x of `jms/serializer` and `jms/serializer-bundle`
116+
117+
* allow to use the Symfony serializer even if the JMS serializer is present
118+
119+
1.7.1
120+
-----
121+
122+
* fix regression when handling methods in `@Route` annotations

Context/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function addGroups(array $groups)
149149
/**
150150
* Gets the normalization groups.
151151
*
152-
* @return array
152+
* @return string[]
153153
*/
154154
public function getGroups()
155155
{
@@ -159,7 +159,7 @@ public function getGroups()
159159
/**
160160
* Set the normalization groups.
161161
*
162-
* @param array $groups
162+
* @param string[] $groups
163163
*
164164
* @return self
165165
*/
@@ -173,7 +173,7 @@ public function setGroups(array $groups)
173173
/**
174174
* Sets the normalization max depth.
175175
*
176-
* @param int|null $depth
176+
* @param int|null $maxDepth
177177
*
178178
* @return self
179179
*/

Controller/ExceptionController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class ExceptionController
2727
{
28+
private $debug;
29+
2830
/**
2931
* @var ViewHandlerInterface
3032
*/

Normalizer/CamelKeysNormalizer.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,30 @@ public function normalize(array $data)
3939
*/
4040
private function normalizeArray(array &$data)
4141
{
42+
$normalizedData = array();
43+
4244
foreach ($data as $key => $val) {
4345
$normalizedKey = $this->normalizeString($key);
4446

4547
if ($normalizedKey !== $key) {
46-
if (array_key_exists($normalizedKey, $data)) {
48+
if (array_key_exists($normalizedKey, $normalizedData)) {
4749
throw new NormalizationException(sprintf(
4850
'The key "%s" is invalid as it will override the existing key "%s"',
4951
$key,
5052
$normalizedKey
5153
));
5254
}
53-
54-
unset($data[$key]);
55-
$data[$normalizedKey] = $val;
56-
$key = $normalizedKey;
5755
}
5856

57+
$normalizedData[$normalizedKey] = $val;
58+
$key = $normalizedKey;
59+
5960
if (is_array($val)) {
60-
$this->normalizeArray($data[$key]);
61+
$this->normalizeArray($normalizedData[$key]);
6162
}
6263
}
64+
65+
$data = $normalizedData;
6366
}
6467

6568
/**
@@ -75,17 +78,8 @@ protected function normalizeString($string)
7578
return $string;
7679
}
7780

78-
if (preg_match('/^(_+)(.*)/', $string, $matches)) {
79-
$underscorePrefix = $matches[1];
80-
$string = $matches[2];
81-
} else {
82-
$underscorePrefix = '';
83-
}
84-
85-
$string = preg_replace_callback('/_([a-zA-Z0-9])/', function ($matches) {
81+
return preg_replace_callback('/_([a-zA-Z0-9])/', function ($matches) {
8682
return strtoupper($matches[1]);
8783
}, $string);
88-
89-
return $underscorePrefix.$string;
9084
}
9185
}

Resources/config/versioning.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<services>
88
<service id="fos_rest.versioning.listener" class="FOS\RestBundle\EventListener\VersionListener">
9-
<argument type="service" id="fos_rest.view_handler.default" />
9+
<argument type="service" id="fos_rest.view_handler" />
1010
<argument type="service" id="fos_rest.versioning.chain_resolver" />
1111
<argument /> <!-- default media type version -->
1212
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="33" />

Resources/doc/3-listener-support.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,25 @@ that the above listeners will not be limited. If at least one zone is configured
207207
be skipped for all requests that do not match at least one zone. For a single zone config entry can contain matching
208208
rules on the request ``path``, ``host``, ``methods`` and ``ip``.
209209

210+
.. code-block:: yaml
211+
212+
# app/config/config.yml
213+
fos_rest:
214+
zone:
215+
- { path: ^/api/* }
216+
217+
Zone Listener
218+
=============
219+
220+
As you can see, FOSRestBundle provides multiple event listeners to enable REST-related features.
221+
By default, these listeners will be registered to all requests and may conflict with other parts of your application.
222+
223+
Using the ``zone`` configuration, you can specify where the event listeners will be enabled. The zone configuration
224+
allows to configure multiple zones in which the above listeners will be active. If no zone is configured, it means
225+
that the above listeners will not be limited. If at least one zone is configured then the above listeners will
226+
be skipped for all requests that do not match at least one zone. For a single zone config entry can contain matching
227+
rules on the request ``path``, ``host``, ``methods`` and ``ip``.
228+
210229
.. code-block:: yaml
211230
212231
# app/config/config.yml

Tests/Context/ContextTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public function testSetGroups()
6060
{
6161
$this->context->setGroups(array('quz', 'foo'));
6262

63-
$this->assertEquals(['quz', 'foo'], $this->context->getGroups());
63+
$this->assertEquals(array('quz', 'foo'), $this->context->getGroups());
6464

65-
$this->context->setGroups(['foo']);
66-
$this->assertEquals(['foo'], $this->context->getGroups());
65+
$this->context->setGroups(array('foo'));
66+
$this->assertEquals(array('foo'), $this->context->getGroups());
6767
}
6868

6969
public function testAlreadyExistentGroupAddition()

Tests/DependencyInjection/FOSRestExtensionTest.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FOSRestExtensionTest extends \PHPUnit_Framework_TestCase
5353
public function setUp()
5454
{
5555
$this->container = new ContainerBuilder();
56-
$this->container->setParameter('kernel.bundles', ['JMSSerializerBundle' => true]);
56+
$this->container->setParameter('kernel.bundles', array('JMSSerializerBundle' => true));
5757
$this->container->setParameter('kernel.debug', false);
5858
$this->extension = new FOSRestExtension();
5959
$this->includeFormat = true;
@@ -551,11 +551,11 @@ public function testExceptionDebug($kernelDebug, $exceptionConfig, $expectedValu
551551
$this->container->setParameter('kernel.debug', $kernelDebug);
552552
$extension = new FOSRestExtension();
553553

554-
$extension->load([
555-
'fos_rest' => [
554+
$extension->load(array(
555+
'fos_rest' => array(
556556
'exception' => $exceptionConfig,
557-
],
558-
], $this->container);
557+
),
558+
), $this->container);
559559

560560
$definition = $this->container->getDefinition('fos_rest.exception.controller');
561561
$this->assertSame($expectedValue, $definition->getArgument(2));
@@ -569,38 +569,38 @@ public function testExceptionDebug($kernelDebug, $exceptionConfig, $expectedValu
569569

570570
public static function getShowExceptionData()
571571
{
572-
return [
573-
'empty config, kernel.debug is true' => [
572+
return array(
573+
'empty config, kernel.debug is true' => array(
574574
true,
575-
[],
575+
array(),
576576
true,
577-
],
578-
'empty config, kernel.debug is false' => [
577+
),
578+
'empty config, kernel.debug is false' => array(
579579
false,
580-
[],
580+
array(),
581581
false,
582-
],
583-
'config debug true' => [
582+
),
583+
'config debug true' => array(
584584
false,
585-
['debug' => true],
585+
array('debug' => true),
586586
true,
587-
],
588-
'config debug false' => [
587+
),
588+
'config debug false' => array(
589589
true,
590-
['debug' => false],
590+
array('debug' => false),
591591
false,
592-
],
593-
'config debug null, kernel.debug true' => [
592+
),
593+
'config debug null, kernel.debug true' => array(
594594
false,
595-
['debug' => null],
595+
array('debug' => null),
596596
true,
597-
],
598-
'config debug null, kernel.debug false' => [
597+
),
598+
'config debug null, kernel.debug false' => array(
599599
false,
600-
['debug' => null],
600+
array('debug' => null),
601601
true,
602-
],
603-
];
602+
),
603+
);
604604
}
605605

606606
/**
@@ -698,14 +698,14 @@ public function testZoneMatcherListener()
698698
$this->assertEquals('addRequestMatcher', $addRequestMatcherCalls[0][0]);
699699
$requestMatcherFirstId = (string) $addRequestMatcherCalls[0][1][0];
700700
$requestMatcherFirst = $this->container->getDefinition($requestMatcherFirstId);
701-
$this->assertInstanceOf(DefinitionDecorator::class, $requestMatcherFirst);
701+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\DefinitionDecorator', $requestMatcherFirst);
702702
$this->assertEquals('/api/*', $requestMatcherFirst->getArgument(0));
703703

704704
// Second zone
705705
$this->assertEquals('addRequestMatcher', $addRequestMatcherCalls[1][0]);
706706
$requestMatcherSecondId = (string) $addRequestMatcherCalls[1][1][0];
707707
$requestMatcherSecond = $this->container->getDefinition($requestMatcherSecondId);
708-
$this->assertInstanceOf(DefinitionDecorator::class, $requestMatcherSecond);
708+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\DefinitionDecorator', $requestMatcherSecond);
709709
$this->assertEquals('/^second', $requestMatcherSecond->getArgument(0));
710710
$this->assertEquals(array('127.0.0.1'), $requestMatcherSecond->getArgument(3));
711711
}

0 commit comments

Comments
 (0)