-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
119 lines (107 loc) · 2.16 KB
/
Copy pathcode.power
File metadata and controls
119 lines (107 loc) · 2.16 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* The Item Class.
*
* @var Item
* @since 5.0.2
*/
protected Item $item;
/**
* Table Name
*
* @var string
* @since 5.0.2
*/
protected string $table;
/**
* Status Field Name
*
* @var string
* @since 5.0.2
*/
protected string $fieldName;
/**
* Constructor.
*
* @param Item $item The Item Class.
* @param string|null $table The table name
* @param string|null $field The field name.
*
* @since 5.0.2
*/
public function __construct(Item $item, ?string $table = null, ?string $field = null)
{
$this->item = $item;
if ($table !== null)
{
$this->table = $table;
}
if ($field !== null)
{
$this->field = $field;
}
}
/**
* Updates the status in the database.
*
* This method updates the import status in the database based on the result of the import process.
*
* @param int $status The status code to set for the import
* @param string $value The target status value
* @param string $key The target key [default: `guid`]
*
* @return void
* @since 5.0.2
*/
public function set(int $status, string $value, $key = 'guid'): void
{
$this->item->table($this->getTable())->set((object) [
$key => $value,
$this->getField() => $status
]);
}
/**
* Set the current active table
*
* @param string $table The table that should be active
*
* @return self
* @since 3.2.2
*/
public function table(string $table): self
{
$this->table = $table;
return $this;
}
/**
* Set the current target status field name
*
* @param string $fieldName The field name where the status is set
*
* @return self
* @since 3.2.2
*/
public function field(string $fieldName): self
{
$this->fieldName = $fieldName;
return $this;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* Get the current target status field name
*
* @return string
* @since 3.2.2
*/
public function getField(): string
{
return $this->fieldName;
}