-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathCartSessionDomainMapper.php
More file actions
52 lines (45 loc) · 1.99 KB
/
CartSessionDomainMapper.php
File metadata and controls
52 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php declare(strict_types=1);
namespace App\Collaboration\Cart\Mapper;
use App\Collaboration\Cart\CartSession;
use Ibexa\Collaboration\Mapper\Domain\ParticipantCollectionDomainMapperInterface;
use Ibexa\Collaboration\Mapper\Domain\SessionDomainMapperInterface;
use Ibexa\Collaboration\Mapper\Domain\UserProxyDomainMapperInterface;
use Ibexa\Collaboration\Persistence\Values\AbstractSession as SessionData;
use Ibexa\Contracts\Collaboration\Session\SessionInterface;
/**
* @template-implements \Ibexa\Collaboration\Mapper\Domain\SessionDomainMapperInterface<
* \App\Collaboration\Cart\Persistence\Values\CartSession
* >
*/
final class CartSessionDomainMapper implements SessionDomainMapperInterface
{
private CartProxyMapperInterface $cartProxyMapper;
private UserProxyDomainMapperInterface $userDomainMapper;
private ParticipantCollectionDomainMapperInterface $participantCollectionDomainMapper;
public function __construct(
CartProxyMapperInterface $cartProxyMapper,
UserProxyDomainMapperInterface $userDomainMapper,
ParticipantCollectionDomainMapperInterface $participantCollectionDomainMapper
) {
$this->cartProxyMapper = $cartProxyMapper;
$this->userDomainMapper = $userDomainMapper;
$this->participantCollectionDomainMapper = $participantCollectionDomainMapper;
}
/**
* @param \App\Collaboration\Cart\Persistence\Values\CartSession $data
*/
public function fromPersistence(SessionData $data): SessionInterface
{
return new CartSession(
$data->getId(),
$this->cartProxyMapper->createCartProxy($data->getCartIdentifier()),
$data->getToken(),
$this->userDomainMapper->createUserProxy($data->getOwnerId()),
$this->participantCollectionDomainMapper->createParticipantCollectionProxy($data->getId()),
$data->isActive(),
$data->hasPublicLink(),
$data->getCreatedAt(),
$data->getUpdatedAt(),
);
}
}