- Issue created by @claudiu.cristea
- @claudiucristea opened merge request.
- π·π΄Romania claudiu.cristea Arad π·π΄
No idea how to solve the value retrieval from the backend (see the step where the test fails)
- Status changed to Postponed: needs info
12 months ago 1:25pm 17 November 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Related: π Allow parsing and writing PHP constants and enums in YAML files Needs work .
I think we can achieve almost the same without adding new concepts:
enum Fruits: string { case APPLE = 'apple'; case PINEAPPLE = 'pineapple'; case PLUM = 'plum'; public static function choices(): array { return array_map(fn ($case) => $case->value, static::cases()); } }
+
mymodule.settings: type: config_object mapping: fruit: type: string constraints: Choice: callback: '\F\Q\C\Fruits::choices'
- Status changed to Active
12 months ago 1:44pm 17 November 2023 - π·π΄Romania claudiu.cristea Arad π·π΄
Well, is doing the job, but you still need to handle scalars and do the conversion in your custom code. Actually, with the
Choice
constraint you can directly enumerate the cases in the schema and youβll drop the enum. Youβre back in pre-enum era.The idea was to offer a nice way to work with enums in your code without the need to know about their scalar representation. Same as for constants
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
without the need to know about their scalar representation
But if in your code you use
Fruits::PLUM->value
, you still don't need to know about the scalar representation? π€ - Status changed to Postponed
12 months ago 2:49pm 17 November 2023 - π·π΄Romania claudiu.cristea Arad π·π΄
@Wim Leers,
Discussed in Slack with @alexpott to rescope this on top of π Allow parsing and writing PHP constants and enums in YAML files Needs work to offer here the schema types and validation part. Postponing on π Allow parsing and writing PHP constants and enums in YAML files Needs work