forked from opengento/magento2-gdpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionEntityBuilder.php
97 lines (74 loc) · 2.3 KB
/
ActionEntityBuilder.php
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
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
90
91
92
93
94
95
96
97
<?php
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/
declare(strict_types=1);
namespace Opengento\Gdpr\Model;
use DateTime;
use Opengento\Gdpr\Api\Data\ActionEntityInterface;
use Opengento\Gdpr\Api\Data\ActionEntityInterfaceFactory;
/**
* @api
*/
final class ActionEntityBuilder
{
/**
* @var ActionEntityInterfaceFactory
*/
private ActionEntityInterfaceFactory $actionEntityFactory;
private array $data;
public function __construct(
ActionEntityInterfaceFactory $actionEntityFactory
) {
$this->actionEntityFactory = $actionEntityFactory;
$this->data = [];
}
public function setType(string $type): ActionEntityBuilder
{
$this->data[ActionEntityInterface::TYPE] = $type;
return $this;
}
public function setPerformedFrom(string $performedFrom): ActionEntityBuilder
{
$this->data[ActionEntityInterface::PERFORMED_FROM] = $performedFrom;
return $this;
}
public function setPerformedBy(string $performedBy): ActionEntityBuilder
{
$this->data[ActionEntityInterface::PERFORMED_BY] = $performedBy;
return $this;
}
public function setPerformedAt(DateTime $performedAt): ActionEntityBuilder
{
$this->data[ActionEntityInterface::PERFORMED_AT] = $performedAt;
return $this;
}
public function setState(string $state): ActionEntityBuilder
{
$this->data[ActionEntityInterface::STATE] = $state;
return $this;
}
public function setMessage(string $message): ActionEntityBuilder
{
$this->data[ActionEntityInterface::MESSAGE] = $message;
return $this;
}
public function setParameters(array $parameters): ActionEntityBuilder
{
$this->data[ActionEntityInterface::PARAMETERS] = $parameters;
return $this;
}
public function setResult(array $result): ActionEntityBuilder
{
$this->data[ActionEntityInterface::RESULT] = $result;
return $this;
}
public function create(): ActionEntityInterface
{
/** @var ActionEntityInterface $actionEntity */
$actionEntity = $this->actionEntityFactory->create(['data' => $this->data]);
$this->data = [];
return $actionEntity;
}
}