Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] Add form type guesser forEnumType#61297
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
30ce63c to0796aa4Compare This comment was marked as outdated.
This comment was marked as outdated.
80d176c to78a2346CompareUh oh!
There was an error while loading.Please reload this page.
1fbb523 toa5eebb2Comparesrc/Symfony/Component/Form/Tests/Fixtures/EnumFormTypeGuesserCase.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| privatefunctiongetPropertyType(string$class,string$property): ?\ReflectionNamedType | ||
| { | ||
| if (isset($this->cache[$class]) &&\array_key_exists($property,$this->cache[$class])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| if (isset($this->cache[$class]) &&\array_key_exists($property,$this->cache[$class])) { | |
| if (isset($this->cache[$class][$property])) { |
| if (!isset($this->cache[$class])) { | ||
| $this->cache[$class] = []; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| if (!isset($this->cache[$class])) { | |
| $this->cache[$class] = []; | |
| } |
| $classReflection =new \ReflectionClass($class); | ||
| $propertyReflection =$classReflection->getProperty($property); | ||
| }catch (\ReflectionException) { | ||
| return$this->cache[$class][$property] =null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| return$this->cache[$class][$property] =null; | |
| return$this->cache[$class][$property] =false; |
| $classReflection =new \ReflectionClass($class); | ||
| $propertyReflection =$classReflection->getProperty($property); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| $classReflection =new \ReflectionClass($class); | |
| $propertyReflection =$classReflection->getProperty($property); | |
| $propertyReflection =new \ReflectionProperty($class,$property); |
| if (!$propertyReflection->getType()instanceof \ReflectionNamedType || !enum_exists($propertyReflection->getType()->getName())) { | ||
| return$this->cache[$class][$property] =null; | ||
| } | ||
| return$this->cache[$class][$property] =$propertyReflection->getType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| if (!$propertyReflection->getType()instanceof \ReflectionNamedType || !enum_exists($propertyReflection->getType()->getName())) { | |
| return$this->cache[$class][$property] =null; | |
| } | |
| return$this->cache[$class][$property] =$propertyReflection->getType(); | |
| $type =$propertyReflection->getType(); | |
| if (!$typeinstanceof \ReflectionNamedType || !enum_exists($enum->getName())) { | |
| $type =false; | |
| } | |
| return$this->cache[$class][$property] =$type; |
a5eebb2 to1e540ebCompare| $container->removeDefinition('form.type_extension.form.html_sanitizer'); | ||
| } | ||
| if (!class_exists(EnumFormTypeGuesser::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would do this insideregisterFormConfiguration()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
1e540eb todc492c9Compare@nicolas-grekas@xabbuh Is there anything more to do for me in this PR? |
Uh oh!
There was an error while loading.Please reload this page.
dc492c9 to7918e76CompareUh oh!
There was an error while loading.Please reload this page.
7918e76 to9e8a923CompareThank you@mttsch. |
87b42a6 intosymfony:7.4Uh oh!
There was an error while loading.Please reload this page.
This new form type guesser guesses the form type of an enum property and also sets the
classoption of theEnumTypeto the relevant enum name.