Skip to content

Commit 2b72834

Browse files
small adjustments
1 parent 99133bf commit 2b72834

18 files changed

+33
-57
lines changed

src/Controller/AbstractApiController.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,13 @@ protected function respond($data, int $statusCode = Response::HTTP_OK): Response
2121
{
2222
$view = $this->view($data, $statusCode);
2323

24-
$serializationGroups = $this->getSerializationGroups();
25-
26-
if (!empty($serializationGroups)) {
27-
$view->getContext()->setGroups($serializationGroups);
24+
if (!empty($this->serializationGroups)) {
25+
$view->getContext()->setGroups($this->serializationGroups);
2826
}
2927

3028
return $this->handleView($view);
3129
}
3230

33-
/**
34-
* @return array
35-
*/
36-
protected function getSerializationGroups(): array
37-
{
38-
return $this->serializationGroups;
39-
}
40-
4131
/**
4232
* @param array $serializationGroups
4333
*/

src/Controller/CustomerStatisticController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use App\Dto\Response\Transformer\CustomerStatisticResponseDtoTransformer;
88
use App\Entity\Customer;
9-
use Symfony\Component\HttpFoundation\Request;
109
use Symfony\Component\HttpFoundation\Response;
1110

1211
class CustomerStatisticController extends AbstractApiController
@@ -18,7 +17,7 @@ public function __construct(CustomerStatisticResponseDtoTransformer $customerSta
1817
$this->customerStatisticResponseDtoTransformer = $customerStatisticResponseDtoTransformer;
1918
}
2019

21-
public function indexAction(Request $request): Response
20+
public function indexAction(): Response
2221
{
2322
$customers = $this->getDoctrine()->getRepository(Customer::class)->findAll();
2423

src/Controller/OrderController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use App\Dto\Response\Transformer\OrderResponseDtoTransformer;
88
use App\Entity\Order;
9-
use Symfony\Component\HttpFoundation\Request;
109
use Symfony\Component\HttpFoundation\Response;
1110

1211
class OrderController extends AbstractApiController
@@ -18,7 +17,7 @@ public function __construct(OrderResponseDtoTransformer $orderResponseDtoTransfo
1817
$this->orderResponseDtoTransformer = $orderResponseDtoTransformer;
1918
}
2019

21-
public function showAction(Request $request): Response
20+
public function showAction(): Response
2221
{
2322
$orders = $this->getDoctrine()->getRepository(Order::class)->findAll();
2423

src/Dto/Response/CustomerResponseDto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use JMS\Serializer\Annotation as Serialization;
88

9-
class CustomerResponseDto implements ResponseDtoInterface
9+
class CustomerResponseDto
1010
{
1111
/**
1212
* @Serialization\Type("string")

src/Dto/Response/CustomerStatisticResponseDto.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
/**
1010
* @Serialization\VirtualProperty(
1111
* "firstName",
12-
* exp="object.getQwe()",
12+
* exp="object.getFirstName()",
1313
* options={@Serialization\SerializedName("my_first_name")}
1414
* )
1515
*/
16-
class CustomerStatisticResponseDto implements ResponseDtoInterface
16+
class CustomerStatisticResponseDto
1717
{
1818
/**
1919
* @Serialization\Type("integer")
@@ -50,8 +50,11 @@ public function setTotalOrdersPrice(\Closure $totalOrdersPrice): void
5050
$this->totalOrdersPrice = $totalOrdersPrice;
5151
}
5252

53-
public function getQwe(): string
53+
/**
54+
* @return string
55+
*/
56+
public function getFirstName(): string
5457
{
55-
return 'qqqqq';
58+
return 'My name';
5659
}
5760
}

src/Dto/Response/OrderResponseDto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use JMS\Serializer\Annotation as Serialization;
88

9-
class OrderResponseDto implements ResponseDtoInterface
9+
class OrderResponseDto
1010
{
1111
/**
1212
* @Serialization\Type("DateTime<'Y-m-d\TH:i:s'>")

src/Dto/Response/ProductResponseDto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use JMS\Serializer\Annotation as Serialization;
88

9-
class ProductResponseDto implements ResponseDtoInterface
9+
class ProductResponseDto
1010
{
1111
/**
1212
* @Serialization\Type("string")

src/Dto/Response/ResponseDtoInterface.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Dto/Response/Transformer/AbstractResponseDtoTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ abstract class AbstractResponseDtoTransformer implements ResponseDtoTransformerI
99
/**
1010
* @inheritdoc
1111
*/
12-
public function transformFromObjects(iterable $items): iterable
12+
public function transformFromObjects(iterable $objects): iterable
1313
{
1414
$dtos = [];
15-
foreach ($items as $item) {
16-
$dtos[] = $this->transformFromObject($item);
15+
foreach ($objects as $object) {
16+
$dtos[] = $this->transformFromObject($object);
1717
}
1818

1919
return $dtos;

src/Dto/Response/Transformer/CustomerResponseDtoTransformer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
namespace App\Dto\Response\Transformer;
66

77
use App\Dto\Response\CustomerResponseDto;
8-
use App\Dto\Response\ResponseDtoInterface;
98
use App\Entity\Customer;
109

1110
class CustomerResponseDtoTransformer extends AbstractResponseDtoTransformer
1211
{
1312
/**
1413
* @param Customer $customer
1514
*
16-
* @return ResponseDtoInterface
15+
* @return mixed
1716
*/
18-
public function transformFromObject($customer): ResponseDtoInterface
17+
public function transformFromObject($customer)
1918
{
2019
$dto = new CustomerResponseDto();
2120
$dto->email = $customer->getEmail();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy