Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Yaml] Allow to get all the enum cases#52230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:7.1fromphansys:yaml_enum
Feb 3, 2024
Merged

Conversation

@phansys
Copy link
Contributor

@phansysphansys commentedOct 22, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
Issuesn/a
LicenseMIT

With this addition, the!php/enum syntax is allowed to expose an array with all the enum cases (the result fromUnitEnum::cases()). This is useful for cases likechoices option from theChoice validation constraint:

BEFORE:

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:

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:

App\Entity\User:properties:status:            -Choice:choices:!php/const 'App\Entity\User::AVAILABLE_STATUSES'

OskarStark and wimleers reacted with thumbs up emoji
@derrabus
Copy link
Member

Please provide a meaningful PR description that explains the feature you're adding, how to use it and what's your motivation behind it. This helps us deciding whether we want to add your feature to Symfony. In addition to that, it helps the documentation team who will probably want to document your feature and announce it in our blog.

phansys and chalasr reacted with thumbs up emoji

@phansys
Copy link
ContributorAuthor

Please provide a meaningful PR description that explains the feature you're adding, how to use it and what's your motivation behind it. This helps us deciding whether we want to add your feature to Symfony. In addition to that, it helps the documentation team who will probably want to document your feature and announce it in our blog.

I've added an example with a use case. Please, let me know if more context is required.
Thank you.

GromNaN reacted with thumbs up emoji

@GromNaN
Copy link
Member

Prior to the support for enumerations, this was allowed by array constants

It is still possible toadd a constant to an enum.
The proposed syntax seems good and concise.

@OskarStarkOskarStark changed the title[Yaml] Allow Yaml component to get all the enum cases[Yaml] Allow to get all the enum casesOct 23, 2023
@fabpot
Copy link
Member

Thank you@phansys.

phansys reacted with hooray emoji

@fabpotfabpot merged commitd00444c intosymfony:7.1Feb 3, 2024
@phansysphansys deleted the yaml_enum branchFebruary 3, 2024 17:28
@fabpotfabpot mentioned this pull requestMay 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

@fabpotfabpotfabpot approved these changes

@GromNaNGromNaNGromNaN approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

7 participants

@phansys@derrabus@GromNaN@fabpot@OskarStark@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp