Skip to content

Commit d993634

Browse files
ralphdoefrantuma
authored andcommitted
samples updates - samples/server/petstore/ze-ph
1 parent 90df339 commit d993634

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

samples/server/petstore/ze-ph/application/config/path_handler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Articus\PathHandler\Router\FastRouteAnnotation:
2626
handlers:
2727
- App\Handler\AnotherFakeDummy
2828
- App\Handler\Fake
29+
- App\Handler\FakeBodyWithQueryParams
2930
- App\Handler\FakeInlineAdditionalProperties
3031
- App\Handler\FakeJsonFormData
3132
- App\Handler\FakeOuterBoolean
@@ -51,6 +52,7 @@ Articus\PathHandler\Router\FastRouteAnnotation:
5152
Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory:
5253
App\Handler\AnotherFakeDummy: []
5354
App\Handler\Fake: []
55+
App\Handler\FakeBodyWithQueryParams: []
5456
App\Handler\FakeInlineAdditionalProperties: []
5557
App\Handler\FakeJsonFormData: []
5658
App\Handler\FakeOuterBoolean: []

samples/server/petstore/ze-ph/src/App/DTO/EnumTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class EnumTest
1414
* @var string
1515
*/
1616
public $enum_string;
17+
/**
18+
* @DTA\Data(field="enum_string_required")
19+
* @DTA\Validator(name="Type", options={"type":"string"})
20+
* @var string
21+
*/
22+
public $enum_string_required;
1723
/**
1824
* @DTA\Data(field="enum_integer", nullable=true)
1925
* @DTA\Validator(name="Type", options={"type":"int"})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\DTO;
4+
5+
use Articus\DataTransfer\Annotation as DTA;
6+
7+
/**
8+
* Query parameters for testBodyWithQueryParams
9+
*/
10+
class TestBodyWithQueryParamsQueryData
11+
{
12+
/**
13+
* @DTA\Data(field="query")
14+
* @DTA\Strategy(name="QueryParameter", options={"type":"string"})
15+
* @DTA\Validator(name="QueryParameterType", options={"type":"string"})
16+
* @var string
17+
*/
18+
public $query;
19+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Handler;
4+
5+
use Articus\PathHandler\Operation;
6+
use Articus\PathHandler\Annotation as PHA;
7+
use Articus\PathHandler\Consumer as PHConsumer;
8+
use Articus\PathHandler\Producer as PHProducer;
9+
use Articus\PathHandler\Attribute as PHAttribute;
10+
use Articus\PathHandler\Exception as PHException;
11+
use Psr\Http\Message\ServerRequestInterface;
12+
13+
/**
14+
* @PHA\Route(pattern="/fake/body-with-query-params")
15+
*/
16+
class FakeBodyWithQueryParams implements Operation\PutInterface
17+
{
18+
/**
19+
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={
20+
* "type":\App\DTO\TestBodyWithQueryParamsQueryData::class,
21+
* "objectAttr":"queryData",
22+
* "source": PHAttribute\Transfer::SOURCE_GET
23+
* })
24+
* TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
25+
* @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json")
26+
* @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"})
27+
* @param ServerRequestInterface $request
28+
*
29+
* @throws PHException\HttpCode 500 if the method is not implemented
30+
*/
31+
public function handlePut(ServerRequestInterface $request)
32+
{
33+
//TODO implement method
34+
/** @var \App\DTO\TestBodyWithQueryParamsQueryData $queryData */
35+
$queryData = $request->getAttribute("queryData");
36+
/** @var \App\DTO\User $bodyData */
37+
$bodyData = $request->getAttribute("bodyData");
38+
throw new PHException\HttpCode(500, "Not implemented");
39+
}
40+
}

0 commit comments

Comments
 (0)