By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.5.x
Introduced in version:
11.5.0
Issue links:
Description:
Drupal now supports PHP constants in YAML files. For example:
parameters:
# this is considered a regular string
foo: PHP_INT_MAX
# this is considered a PHP constant
bar: !php/const PHP_INT_MAX
Will be read as
[
"parameters" => [
"foo" => "PHP_INT_MAX",
"bar" => 9223372036854775807,
],
]
This also allows us to support enums in config and service yamls too. For example:
enum Suit {
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
$data = [
'suit' => Suit::Hearts
];
dump(\Drupal\Component\Serialization\Yaml::encode($data));
Produces the following YAML:
suit: !php/const Suit::Hearts
Impacts:
Module developers