-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.4: synchronize Redis proxy traits for different versions [Serializer] Fixed BackedEnumNormalizer priority for translatable enum [Config] Fix `YamlReferenceDumper` handling of array examples
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Fixtures; | ||
|
||
use Symfony\Contracts\Translation\TranslatableInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
enum TranslatableBackedEnum: string implements TranslatableInterface | ||
{ | ||
case Get = 'GET'; | ||
|
||
public function trans(TranslatorInterface $translator, ?string $locale = null): string | ||
{ | ||
return match ($this) { | ||
self::Get => 'custom_get_string', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\TranslatableBackedEnum; | ||
|
||
/** | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
|
@@ -67,6 +69,15 @@ public static function provideNormalizersAndEncodersWithDefaultContextOption(): | |
['serializer.encoder.csv.alias'], | ||
]; | ||
} | ||
|
||
public function testSerializeTranslatableBackedEnum() | ||
{ | ||
static::bootKernel(['test_case' => 'Serializer']); | ||
|
||
$serializer = static::getContainer()->get('serializer.alias'); | ||
|
||
$this->assertEquals('GET', $serializer->serialize(TranslatableBackedEnum::Get, 'yaml')); | ||
} | ||
} | ||
|
||
class Foo | ||
|