-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from picamator/development
Release 1.5.0
- Loading branch information
Showing
54 changed files
with
843 additions
and
86 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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Picamator\Doc\Samples\TransferObject\Advanced; | ||
|
||
use Picamator\TransferObject\Transfer\DummyTransferAdapterTrait; | ||
use Picamator\TransferObject\Transfer\TransferInterface; | ||
|
||
class CredentialsData implements TransferInterface | ||
{ | ||
use DummyTransferAdapterTrait; | ||
|
||
public string $login { | ||
get => $this->login; | ||
set => $this->login = $value; | ||
} | ||
|
||
public string $token { | ||
get => $this->token; | ||
set => $this->token = $value; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
doc/samples/Generated/AdvancedTransferGenerator/AdvancedCustomerTransfer.php
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
doc/samples/config/advanced-transfer-generator/definition/advanced-customer.transfer.yml
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,5 @@ | ||
AdvancedCustomer: | ||
customer: | ||
type: "Picamator\\Doc\\Samples\\TransferObject\\Generated\\TransferGenerator\\CustomerTransfer" | ||
credentials: | ||
type: "Picamator\\Doc\\Samples\\TransferObject\\Advanced\\CredentialsData" |
4 changes: 4 additions & 0 deletions
4
doc/samples/config/advanced-transfer-generator/generator.config.yml
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,4 @@ | ||
generator: | ||
transferNamespace: "Picamator\\Doc\\Samples\\TransferObject\\Generated\\AdvancedTransferGenerator" | ||
transferPath: "${PROJECT_ROOT}/doc/samples/Generated/AdvancedTransferGenerator" | ||
definitionPath: "${PROJECT_ROOT}/doc/samples/config/advanced-transfer-generator/definition" |
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,110 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Picamator\Doc\Samples\TransferObject\Advanced\CredentialsData; | ||
use Picamator\Doc\Samples\TransferObject\Generated\AdvancedTransferGenerator\AdvancedCustomerTransfer; | ||
use Picamator\Doc\Samples\TransferObject\Generated\TransferGenerator\CustomerTransfer; | ||
use Picamator\TransferObject\TransferGenerator\TransferGeneratorFacade; | ||
|
||
require_once __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
echo <<<'STORY' | ||
========================================================= | ||
How to use custom Data Transfer Object | ||
& | ||
apply Transfer Object cross modules link | ||
========================================================= | ||
|
||
STORY; | ||
|
||
echo <<<'STORY' | ||
============================================================================ | ||
Lets take CustomerTransfer form Generated\TransferGenerator | ||
============================================================================ | ||
|
||
STORY; | ||
$customerTransfer = new CustomerTransfer(); | ||
$customerTransfer->firstName = 'Jan'; | ||
$customerTransfer->lastName = 'Kowalski'; | ||
|
||
echo <<<'STORY' | ||
============================================================================ | ||
Lets take CredentialsData form Advanced | ||
& | ||
implements TransferInterface using DummyTransferAdapterTrait | ||
============================================================================ | ||
|
||
STORY; | ||
$credentialsData = new CredentialsData(); | ||
$credentialsData->login = 'jan.kowalski'; | ||
$credentialsData->token = 'some-random-token'; | ||
|
||
$encodedCredentialsData = json_encode($credentialsData); | ||
|
||
$serializedCredentialsData = serialize($credentialsData); | ||
$unserializedCredentialsData = unserialize($serializedCredentialsData); | ||
|
||
$iteratedCredentialsData = implode(', ', iterator_to_array($credentialsData->getIterator())); | ||
|
||
echo <<<DEBUG | ||
Count: {$credentialsData->count()} | ||
JSON encode: $encodedCredentialsData | ||
Serialized: $serializedCredentialsData | ||
Iterated: [$iteratedCredentialsData] | ||
DEBUG; | ||
|
||
echo <<<'STORY' | ||
=================================================================== | ||
Create a Definition file combining both objects | ||
=================================================================== | ||
AdvancedCustomer: | ||
customer: | ||
type: 'Picamator\\Doc\\Samples\\TransferObject\\Generated\\TransferGenerator\\CustomerTransfer' | ||
credentials: | ||
type: 'Picamator\\Doc\\Samples\\TransferObject\\Advanced\\CredentialsData' | ||
|
||
|
||
STORY; | ||
|
||
echo <<<'STORY' | ||
====================================================== | ||
Generate Transfer Objects | ||
====================================================== | ||
|
||
STORY; | ||
$configPath = __DIR__ . '/config/advanced-transfer-generator/generator.config.yml'; | ||
new TransferGeneratorFacade()->generateTransfersOrFail($configPath); | ||
|
||
echo <<<'STORY' | ||
====================================================== | ||
Try newly Generated Transfer Object | ||
& | ||
Debug | ||
====================================================== | ||
|
||
STORY; | ||
|
||
$advancedCustomerTransfer = new AdvancedCustomerTransfer(); | ||
$advancedCustomerTransfer->customer = $customerTransfer; | ||
$advancedCustomerTransfer->credentials = $credentialsData; | ||
|
||
var_dump($advancedCustomerTransfer->toArray()); | ||
|
||
echo <<<'STORY' | ||
====================================================== | ||
Convert fromArray | ||
====================================================== | ||
|
||
STORY; | ||
$advancedCustomerTransfer = new AdvancedCustomerTransfer()->fromArray([ | ||
AdvancedCustomerTransfer::CUSTOMER => [ | ||
CustomerTransfer::FIRST_NAME => 'Max', | ||
CustomerTransfer::LAST_NAME => 'Mustermann', | ||
], | ||
AdvancedCustomerTransfer::CREDENTIALS => [], | ||
]); | ||
|
||
var_dump($advancedCustomerTransfer->toArray()); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.