Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #52230 [Yaml] Allow to get all the enum cases (phansys)
This PR was merged into the 7.1 branch. Discussion ---------- [Yaml] Allow to get all the enum cases | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | n/a | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> With this addition, the `!php/enum` syntax is allowed to expose an array with all the enum cases (the result from [`UnitEnum::cases()`](https://www.php.net/manual/en/unitenum.cases.php)). This is useful for cases like `choices` option from the `Choice` validation constraint: **BEFORE**: ```yaml App\Entity\User: properties: status: - Choice: choices: - !php/enum 'App\Entity\Enum\UserStatus::Enabled' - !php/enum 'App\Entity\Enum\UserStatus::Disabled' - !php/enum 'App\Entity\Enum\UserStatus::Blocked' ``` **AFTER**: ```yaml App\Entity\User: properties: status: - Choice: choices: !php/enum 'App\Entity\Enum\UserStatus' ``` Prior to the support for enumerations, this was allowed by array constants: ```yaml App\Entity\User: properties: status: - Choice: choices: !php/const 'App\Entity\User::AVAILABLE_STATUSES' ``` Commits ------- 3286539bef [Yaml] Allow Yaml component to get all the enum cases
- Loading branch information