Skip to content

Commit 671b446

Browse files
authored
Merge pull request #1252 from meyerbaptiste/allow_php_constants_yaml_resources_files
Allow using PHP constants in YAML resources files
2 parents 55851fd + b9f7aaf commit 671b446

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/Metadata/Extractor/YamlExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class YamlExtractor extends AbstractExtractor
3232
protected function extractPath(string $path)
3333
{
3434
try {
35-
$resourcesYaml = Yaml::parse(file_get_contents($path), Yaml::PARSE_KEYS_AS_STRINGS);
35+
$resourcesYaml = Yaml::parse(file_get_contents($path), Yaml::PARSE_KEYS_AS_STRINGS | Yaml::PARSE_CONSTANT);
3636
} catch (ParseException $e) {
3737
$e->setParsedFile($path);
3838

tests/Fixtures/FileConfigurations/resources.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resources:
1919
groups: ['default']
2020
hydra_context:
2121
'@type': 'hydra:Operation'
22-
'@hydra:title': 'File config Dummy'
22+
'@hydra:title': !php/const:ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy::HYDRA_TITLE
2323
iri: 'someirischema'
2424
properties:
2525
'foo':

tests/Fixtures/TestBundle/Entity/FileConfigDummy.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
class FileConfigDummy
2424
{
25+
const HYDRA_TITLE = 'File config Dummy';
26+
2527
/**
2628
* @var int The id
2729
*

0 commit comments

Comments
 (0)