bankiru /
doctrine-api-client
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Bankiru\Api\Doctrine\Rpc; |
||
| 4 | |||
| 5 | use Bankiru\Api\Doctrine\Mapping\ApiMetadata; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Example implementation for API-capable communicator |
||
| 9 | * following Doctrine arguments layout for objects fetching |
||
| 10 | * |
||
| 11 | * @internal |
||
| 12 | */ |
||
| 13 | final class DoctrineApi extends SingleRequestApi |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 14 | { |
||
| 15 | const METHOD_FIND = 'find'; |
||
| 16 | const METHOD_SEARCH = 'search'; |
||
| 17 | const METHOD_COUNT = 'count'; |
||
| 18 | |||
| 19 | private static $params = [ |
||
| 20 | 'criteria', |
||
| 21 | 'sort', |
||
| 22 | 'limit', |
||
| 23 | 'offset', |
||
| 24 | ]; |
||
| 25 | |||
| 26 | /** {@inheritdoc} */ |
||
| 27 | protected function createCountRequest(ApiMetadata $metadata, array $criteria) |
||
| 28 | { |
||
| 29 | return new RpcRequest( |
||
| 30 | $metadata->getMethodContainer()->getMethod(self::METHOD_COUNT), |
||
| 31 | ['criteria' => $criteria] |
||
| 32 | ); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** {@inheritdoc} */ |
||
| 36 | protected function createFindRequest(ApiMetadata $metadata, array $identifier) |
||
| 37 | { |
||
| 38 | return new RpcRequest( |
||
| 39 | $metadata->getMethodContainer()->getMethod(self::METHOD_FIND), |
||
| 40 | $identifier |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** {@inheritdoc} */ |
||
| 45 | protected function createSearchRequest(ApiMetadata $metadata, array $parameters) |
||
| 46 | { |
||
| 47 | return new RpcRequest( |
||
| 48 | $metadata->getMethodContainer()->getMethod(self::METHOD_SEARCH), |
||
| 49 | array_combine(self::$params, $parameters) |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |