-
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1090 [LiveComponent] Implement hydratation of DTO object (ma…
…theo, WebMamba) This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Implement hydratation of DTO object | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | Fix #955 | License | MIT With this PR you van easily use DTO with your LiveComponents. ```php class CustomerDetails { public string $name; public Address $address; public string $city; } ``` ```php class Address { public string $street; public string $postCode; } ``` ```php #[AsLiveComponent(name: 'CustomerDetails')] class CustomerDetailsComponent { use DefaultActionTrait; #[ExposeInTemplate] public string $hello = 'hello'; #[LiveProp(writable: true)] public ?CustomerDetails $customerDetails = null; public function mount(): void { $this->customerDetails = new CustomerDetails(); $this->customerDetails->name = 'Matheo'; $this->customerDetails->city = 'Paris'; $this->customerDetails->address = new Address(); $this->customerDetails->address->street = '3 rue de la Paix'; $this->customerDetails->address->postCode = '92270'; } #[LiveAction] public function switch(): void { $this->customerDetails = new CustomerDetails(); $this->customerDetails->name = 'Paul'; $this->customerDetails->city = 'Paris'; $this->customerDetails->address = new Address(); $this->customerDetails->address->street = '3 rue des mimosas'; $this->customerDetails->address->postCode = '92270'; } } ``` ```twig <div {{ attributes }}> <p>{{ customerDetails.name }}</p> <p>{{ customerDetails.address.street }}</p> <button data-action="live#action" data-action-name="switch" >Switch</button> </div> ``` Commits ------- 970ba16 fix Doc ci ba53343 fix exeception and use PropertyAccessor to read the value 6e4854d Update docs feb1f44 rewrite errors and renames variable 28e3b39 edit error message 30d4fdb add doc 9d738d6 refactoring and renaming 11b9210 Remove checksum in tests 7595c70 Tests and centralize logic in LiveComponentMetadataFactory bd7e719 use LiveComponentMetadataFactory logic to generate LivePropMetadata bac591e Implement hydratation of DTO object
- Loading branch information
Showing
8 changed files
with
230 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Dto; | ||
|
||
class Address | ||
{ | ||
public string $address; | ||
public string $city; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Dto; | ||
|
||
class CustomerDetails | ||
{ | ||
public string $firstName; | ||
public string $lastName; | ||
|
||
public Address $address; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.