-
-
Couldn't load subscription status.
- Fork 5.3k
[PropertyAccess] Custom methods on property accesses #6400
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c943984 to 8763757 Compare | Guys, just a quick question. I was expecting a plataformsh automatic documentation deploy of this PR but found none. Has the feature been discontinued or am I just doing something wrong? |
| This seems to be a general issue with Platform.sh. @GuGuss can you help us here (this seems to affect all recent pull requests)? |
| <Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::setMetadataFactory>` | ||
| see `Enable other Features`_. | ||
| | ||
| There are four method calls that can be overriden: `getter`, `setter`, `adder` and |
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.
Minor syntax issue: in Markdown you can use this:
`getter`, `setter`, `adder` and `remover` but in RST you must use double backticks:
``getter``, ``setter``, ``adder`` and ``remover`` | @lrlopez this is truly a useful feature. I hope it's included in Symfony soon! Thank you also for providing the docs for the feature. |
| @javiereguiluz Thank you very much for the review! |
ba1c468 to 3aa2e31 Compare | All comments have been addressed |
7375b21 to cd683e7 Compare cd683e7 to 88622d5 Compare | Docs ready for final review! |
88622d5 to 8b788ba Compare 8b788ba to 17a6fdd Compare | Docs have been rebased to latest master so no conflicts arise anymore. By the way, related PR are now symfony/symfony#22190 and symfony/symfony#22191 |
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.
Thanks for documenting this awesome feature :)
| Custom method calls and virtual properties in a class | ||
| ----------------------------------------------------- | ||
| | ||
| Sometimes you may not want the component to guess which method has to be called |
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.
This needs a .. versionadded:: directive.
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.
Should I target 3.3 or 3.4? I think is 3.4, but I'd like to be sure
components/property_access.rst Outdated
| .. code-block:: php-annotations | ||
| // ... | ||
| use Symfony\Component\PropertyAccess\Annotation\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.
It does make sense to name the annotation class PropertyAccess but maybe it is worth an alias, wdyt?
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.
Hmmm... I've been thinking all the day around about renaming the annotation class to Accessor. Do you think is better?
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.
Maybe, but it would not be that consistent with the other, so what about:
/** * @PropertyAcessor(...) */ private $property; /** * @GetterAccessor(...) */ public function propertyState() { // ... } /** * @SetterAccessor(...) */ public function updateProperty() { // ... } /** * @AdderAccessor(...) */ public function increaseProperty(Arg $arg) { // ... } /** * @RemoverAccessor(...) */ public function decreaseProperty(Arg $arg) { // ... }WDYT?
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.
Ok, let's do this way then! We can change later them if we don't like the results...
components/property_access.rst Outdated
| // Notice that there is no real "total" property | ||
| /** | ||
| * @PropertyGetter(property="total") |
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.
@HeahDude, we could rename this annotation to just Getter and do the same to the others (Setter, Adder and Remover). Do you agree?
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.
It seems I've answered above at the same time :). I don't know what's best though.
f4d4ff2 to 1abbb44 Compare 1abbb44 to 5f4e4b6 Compare | Although it may not be needed, I've squashed the commits. |
| Code PR closed |
Uh oh!
There was an error while loading. Please reload this page.