You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Encapsulates the configuration for a CEL runtime environment.
@@ -15,6 +18,11 @@
15
18
*/
16
19
finalreadonlyclass Configuration
17
20
{
21
+
/**
22
+
* @var array<class-string<MessageInterface>, list<string>> A reverse mapping of message class names to their aliases for quick lookup.
23
+
*/
24
+
publicarray$messageClassesToAliases;
25
+
18
26
/**
19
27
* @param bool $enableMacros Whether to enable macro support (e.g., `has()`, `all()`).
20
28
* @param bool $enableCoreExtension Whether to enable the core extension (e.g., `size()`, type conversions).
@@ -24,6 +32,13 @@
24
32
* @param bool $enableListExtension Whether to enable the list extension (e.g., `sort()`, `chunk()`).
25
33
* @param list<class-string<MessageInterface>> $allowedMessageClasses A security-focused allowlist of message classes that can be constructed within an expression.
26
34
* Classes must implement `MessageInterface`. By default, no message construction is allowed.
35
+
* @param array<string, class-string<MessageInterface>> $messageClassAliases An optional mapping of custom type names to fully qualified message class names.
36
+
* This allows using shorter or more convenient names in expressions.
37
+
* @param bool $enforceMessageClassAliases Whether to enforce the use of message class aliases when constructing messages.
38
+
* If true, a class in `$allowedMessageClasses` that also has an alias in `$messageClassAliases`
39
+
* can only be constructed using its alias.
40
+
*
41
+
* @throws MisconfigurationException if any alias in `$messageClassAliases` does not map to a class in `$allowedMessageClasses`.
* Creates a configuration that allows constructing only the specified message classes.
@@ -42,11 +78,22 @@ public function __construct(
42
78
* from being instantiated within CEL expressions.
43
79
*
44
80
* @param list<class-string<MessageInterface>> $allowedMessageClasses The list of allowed message classes.
81
+
* @param array<string, class-string<MessageInterface>> $messageClassAliases An optional mapping of custom type names to fully qualified message class names.
82
+
* @param bool $enforceMessageClassAliases Whether to enforce the use of message class aliases when constructing messages.
45
83
*
46
84
* @return self The configuration instance with the specified allowed message classes.
85
+
*
86
+
* @throws MisconfigurationException if any alias in `$messageClassAliases` does not map to a class in `$allowedMessageClasses`.
0 commit comments