From 3d7a36761cab45f7b502beba34cfbe58fdb4edbb Mon Sep 17 00:00:00 2001 From: AlexP Date: Mon, 20 May 2024 12:16:37 +0500 Subject: [PATCH] STA-1046 | fix listing clollection --- .../Collection/RestaurantListingElementCollection.php | 10 +++++++++- app/src/Restaurants/Dto/RestaurantListDto.php | 6 +++--- .../DtoFactory/RestaurantListDtoFactory.php | 6 +++--- .../DtoFactory/RestaurantListingElementDtoFactory.php | 8 ++++---- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/src/Restaurants/Collection/RestaurantListingElementCollection.php b/app/src/Restaurants/Collection/RestaurantListingElementCollection.php index da84473..8cc388c 100644 --- a/app/src/Restaurants/Collection/RestaurantListingElementCollection.php +++ b/app/src/Restaurants/Collection/RestaurantListingElementCollection.php @@ -2,7 +2,15 @@ namespace App\Restaurants\Collection; -class RestaurantLisitngElementCollection +use App\Restaurants\Dto\RestaurantListingElementDto; +use App\Shared\Collection\DtoCollection; + +class RestaurantListingElementCollection extends DtoCollection { + private string $collectionType = RestaurantListingElementDto::class; + public function __construct(array $data = []) + { + parent::__construct($this->collectionType, $data); + } } \ No newline at end of file diff --git a/app/src/Restaurants/Dto/RestaurantListDto.php b/app/src/Restaurants/Dto/RestaurantListDto.php index 1e6ac5d..8695625 100644 --- a/app/src/Restaurants/Dto/RestaurantListDto.php +++ b/app/src/Restaurants/Dto/RestaurantListDto.php @@ -2,19 +2,19 @@ namespace App\Restaurants\Dto; -use App\Shared\Collection\ListingCollection; +use App\Restaurants\Collection\RestaurantListingElementCollection; use App\Shared\Dto\PaginationDto; class RestaurantListDto { /** * @param PaginationDto $pagination - * @param ListingCollection $list + * @param RestaurantListingElementCollection $list * @param RestaurantFilterVariantsDto $filterVariants */ public function __construct( public PaginationDto $pagination, - public ListingCollection $list, + public RestaurantListingElementCollection $list, public RestaurantFilterVariantsDto $filterVariants, ) {} } diff --git a/app/src/Restaurants/DtoFactory/RestaurantListDtoFactory.php b/app/src/Restaurants/DtoFactory/RestaurantListDtoFactory.php index 66ca9e8..c28d740 100644 --- a/app/src/Restaurants/DtoFactory/RestaurantListDtoFactory.php +++ b/app/src/Restaurants/DtoFactory/RestaurantListDtoFactory.php @@ -2,23 +2,23 @@ namespace App\Restaurants\DtoFactory; +use App\Restaurants\Collection\RestaurantListingElementCollection; use App\Restaurants\Dto\RestaurantFilterVariantsDto; use App\Restaurants\Dto\RestaurantListDto; use App\Restaurants\Dto\RestaurantListingElementDto; -use App\Shared\Collection\ListingCollection; use App\Shared\Dto\PaginationDto; class RestaurantListDtoFactory { /** * @param PaginationDto $pagination - * @param ListingCollection $list + * @param RestaurantListingElementCollection $list * @param RestaurantFilterVariantsDto $filters * @return RestaurantListDto */ public function create( PaginationDto $pagination, - ListingCollection $list, + RestaurantListingElementCollection $list, RestaurantFilterVariantsDto $filters ): RestaurantListDto { return new RestaurantListDto( diff --git a/app/src/Restaurants/DtoFactory/RestaurantListingElementDtoFactory.php b/app/src/Restaurants/DtoFactory/RestaurantListingElementDtoFactory.php index 6fa858d..7c0066d 100644 --- a/app/src/Restaurants/DtoFactory/RestaurantListingElementDtoFactory.php +++ b/app/src/Restaurants/DtoFactory/RestaurantListingElementDtoFactory.php @@ -2,8 +2,8 @@ namespace App\Restaurants\DtoFactory; +use App\Restaurants\Collection\RestaurantListingElementCollection; use App\Restaurants\Dto\RestaurantListingElementDto; -use App\Shared\Collection\ListingCollection; use App\Shared\DtoFactory\FileDtoFactory; use App\Shared\Entity\Restaurants; use Ramsey\Collection\Collection; @@ -29,14 +29,14 @@ class RestaurantListingElementDtoFactory /** * @param Collection $restaurants - * @return ListingCollection + * @return RestaurantListingElementCollection */ - public function createCollection(Collection $restaurants): ListingCollection + public function createCollection(Collection $restaurants): RestaurantListingElementCollection { $restaurantsDto = $restaurants->map(function(Restaurants $restaurant) { return $this->create($restaurant); }); - return new ListingCollection($restaurantsDto->toArray()); + return new RestaurantListingElementCollection($restaurantsDto->toArray()); } } -- GitLab