, (*1)
This package provides a Transform Middleware leveraging Transform and Stash., (*2)
Installation
To install, use composer:, (*3)
composer require flipboxdigital/relay-transform
Testing
``` bash
$ ./vendor/bin/phpunit, (*4)
## Usage
```php
$request = new Zend\Diactoros\Request();
$response = new Zend\Diactoros\Response();
$data = [
'firstName' => 'foo',
'lastName' => 'bar',
'dateCreated' => new \DateTime(),
'dateUpdated' => new \DateTime()
];
$queue = [
[
'class' => Flipbox\Relay\Middleware\Transform\Item::class,
'data' => $data,
'transformer' => function($data) {
return [
'name' => [
'first' => $data['firstName'],
'last' => $data['firstName']
],
'date' => [
'created' => $data['dateCreated']->format('c'),
'updated' => $data['dateUpdated']->format('c')
]
]
}
]
];
// Relay runner
$runner = new Runner(
$queue,
RelayHelper::createResolver()
);
// Relay runner
$runner = new Relay\Runner(
$queue,
Flipbox\Relay\Helpers\RelayHelper::createResolver()
);
// Run
$response = $runner($request, $response);
Contributing
Please see CONTRIBUTING for details., (*5)
Credits
License
The MIT License (MIT). Please see License File for more information., (*6)