-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
[LiveComponent] Property does not exist exception when a LiveProp object has a virtual method? #1589
Comments
Could you show us how you call this method from your template ? |
@smnandre thanks for helping, I'm not even printing the product in my template. The error is raised from a live listener: #[LiveProp]
public ?Product $product = null;
#[LiveListener("barcode_scanned")]
public function onScan(#[LiveArg()] string $value): void
{
$envelope = $this->messageBus->dispatch(
new FetchProductMessage($value, $this->order->customer, $this->profile)
);
$product = $envelope->last(HandledStamp::class)->getResult();
$this->product = $product;
} |
You may need to show more code, because i see nowhere where is the At least you should give a bit more details concerning this exception, where it is raised, etc. |
So we can close this issue, as it's replaced by #1590 right ? |
There are two different issues, just naming are similar, a bit confusing Indeed... |
@smnandre to be clear: I get that error for any "virtual" property of my DTO. It may be related to the hydration problem explained here, because Symfony doesn't know how to set back the value when the hydrate occurs (and indeed it looks for a property named It would be a nice idea to allow to exclude those "virtual properties". What If I only need For example "Do not try to dehydrate/hydrate this property": #[LiveIgnore]
public function getDiscountedUnitPrice(): ?float
{
return $this->discount?->calculate($this->unitPrice) ?? $this->unitPrice;
} |
Thank you for this issue. |
I think isn't resolved yet. |
Could you please create a small reproducer (the minimal app possible to reproduce / observe / investigate the bug) ? It really is the best method, so we can pull some repository and immediately work on it :) |
Yes @smnandre it's ok to provide a container for running the example or you do by your own? |
A small repository with minimal install would be ideal :) See |
Repo: https://github.com/gremo/github-issue-1589
|
If you have time to suggest a fix we'll look at it, but we're reworking this part currently and this is such a weird case... did you try with custom hydration ? |
Hi, One solution I've found to solve the problem on my side is to use the #[LiveProp(useSerializerForHydration: true)]
public ?Product $product = null; |
My object is set as a
LiveProp
inside a Live component. It's a plain DTO with a method added, a virtual one, namedgetDiscountedUnitPrice
:As soon as my DTO become a
LiveProp
, I get the following error:If you name the method
discountedUnitPrice
it works like a charm. I think this is a bug to be addressed.The text was updated successfully, but these errors were encountered: