flipboxdigital / relay-transform
Transform Middleware for Relay
Installs: 5 776
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- flipboxdigital/http-stream: ^2.0
- flipboxdigital/relay: ^2.0
- flipboxdigital/transform: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^2.0
This package is auto-updated.
Last update: 2024-12-09 14:39:58 UTC
README
This package provides a Transform Middleware leveraging Transform and Stash.
Installation
To install, use composer:
composer require flipboxdigital/relay-transform
Testing
$ ./vendor/bin/phpunit
Usage
$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.
Credits
License
The MIT License (MIT). Please see License File for more information.