Newer
Older
<?php
namespace App\Mapper;
use App\Entity\Address;
use App\Entity\Email;
use App\Entity\Restaurant;
use App\Entity\RestaurantType;
use App\Model\File;
use App\Model\KitchenType;
use App\Model\RestaurantDetailElement;
use App\Model\RestaurantListingElement;
use App\Model\RestaurantType as RestaurantTypeModel;
use App\Model\Tag;
use Ramsey\Collection\Collection;
class RestaurantMapper
{
public static function mapToListElement(Restaurant $restaurant): RestaurantListingElement
{
return new RestaurantListingElement(
$restaurant->getId(),
$restaurant->getName(),
$restaurant->getCode(),
new RestaurantTypeModel(
$restaurant->getTypeId()->getId(),
$restaurant->getTypeId()->getName(),
$restaurant->getTypeId()->getCode()
),
$restaurant->getCheckInfo(),
new File(
1,
"name",
"description",
10,
"jpg",
$restaurant->getPreviewImage()
),
$restaurant->getSite()
);
}
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
public static function mapToDetailElement(Restaurant $restaurant): RestaurantDetailElement
{
$file = new File(
1,
"name",
"description",
10,
"jpg",
$restaurant->getPreviewImage()
);
return new RestaurantDetailElement(
$restaurant->getId(),
$restaurant->getName(),
$restaurant->getCode(),
implode(',', $restaurant->getCoordinates()),
//self::mapToRestaurantType($restaurant->getTypeId()),
$restaurant->getCheckPrice(),
$restaurant->getCheckInfo(),
new Collection(
KitchenType::class, array_map(
function (Kitchen $kitchen) {
return self::mapToKitchenType($kitchen);
}, $restaurant->getKitchen()->toArray()),
),
new Collection(Phone::class, $restaurant->getPhone()->toArray()),
new Collection(Email::class, $restaurant->getEmail()->toArray()),
new Collection(Address::class, $restaurant->getAddress()->toArray()),
new Collection(Tag::class, array_map(
function (Tags $tag) {
return new Tag(
"группа тегов 1",
new Collection($tag->getName()),
);
}, $restaurant->getTags()->toArray()
)),
$restaurant->getSite(),
$file,
new Collection(File::class, [$file]),
"Отель Арктика",
"otel arktika",
"otel arktika"
);
}
public static function mapToRestaurantType(RestaurantType $restaurantType): RestaurantTypeModel
{
return new RestaurantTypeModel(
$restaurantType->getId(),
$restaurantType->getName(),