8000 Merge branch '2.8' into 3.0 · symfony/symfony@c87c35e · GitHub
[go: up one dir, main page]

Skip to content

Commit c87c35e

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: bumped Symfony version to 2.8.5 updated VERSION for 2.8.4 updated CHANGELOG for 2.8.4 bumped Symfony version to 2.7.12 updated VERSION for 2.7.11 updated CHANGELOG for 2.7.11 [Request] Fix support of custom mime types with parameters fix mocks fix mocks [Validator] do not treat payload as callback
2 parent
10000
s f4c9988 + df01f06 commit c87c35e

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,9 @@ public function getMimeType($format)
13301330
*/
13311331
public function getFormat($mimeType)
13321332
{
1333+
$canonicalMimeType = null;
13331334
if (false !== $pos = strpos($mimeType, ';')) {
1334-
$mimeType = substr($mimeType, 0, $pos);
1335+
$canonicalMimeType = substr($mimeType, 0, $pos);
13351336
}
13361337

13371338
if (null === static::$formats) {
@@ -1342,6 +1343,9 @@ public function getFormat($mimeType)
13421343
if (in_array($mimeType, (array) $mimeTypes)) {
13431344
return $format;
13441345
}
1346+
if (null !== $canonicalMimeType && in_array($canonicalMimeType, (array) $mimeTypes)) {
1347+
return $format;
1348+
}
13451349
}
13461350
}
13471351

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ public function testGetMimeTypeFromFormat($format, $mimeTypes)
325325
}
326326
}
327327

328+
public function testGetFormatWithCustomMimeType()
329+
{
330+
$request = new Request();
331+
$request->setFormat('custom', 'application/vnd.foo.api;myversion=2.3');
332+
$this->assertEquals('custom', $request->getFormat('application/vnd.foo.api;myversion=2.3'));
333+
}
334+
328335
public function getFormatToMimeTypeMapProvider()
329336
{
330337
return array(

src/Symfony/Component/Validator/Constraints/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($options = null)
3838
$options = $options['value'];
3939
}
4040

41-
if (is_array($options) && !isset($options['callback']) && !isset($options['groups'])) {
41+
if (is_array($options) && !isset($options['callback']) && !isset($options['groups']) && !isset($options['payload'])) {
4242
$options = array('callback' => $options);
4343
}
4444

src/Symfony/Component/Validator/Tests/Fixtures/Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getData()
8585
}
8686

8787
/**
88-
* @Assert\Callback
88+
* @Assert\Callback(payload="foo")
8989
*/
9090
public function validateMe(ExecutionContextInterface $context)
9191
{

src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testLoadClassMetadata()
5353
$expected->setGroupSequence(array('Foo', 'Entity'));
5454
$expected->addConstraint(new ConstraintA());
5555
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
56-
$expected->addConstraint(new Callback('validateMe'));
56+
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
5757
$expected->addConstraint(new Callback('validateMeStatic'));
5858
$expected->addPropertyConstraint('firstName', new NotNull());
5959
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));
@@ -123,7 +123,7 @@ public function testLoadClassMetadataAndMerge()
123123
$expected->setGroupSequence(array('Foo', 'Entity'));
124124
$expected->addConstraint(new ConstraintA());
125125
$expected->addConstraint(new Callback(array('Symfony\Component\Validator\Tests\Fixtures\CallbackClass', 'callback')));
126-
$expected->addConstraint(new Callback('validateMe'));
126+
$expected->addConstraint(new Callback(array('callback' => 'validateMe', 'payload' => 'foo')));
127127
$expected->addConstraint(new Callback('validateMeStatic'));
128128
$expected->addPropertyConstraint('firstName', new NotNull());
129129
$expected->addPropertyConstraint('firstName', new Range(array('min' => 3)));

0 commit comments

Comments
 (0)
0