Bristol SU Support Package
src
Action
History
HasHistory.php
Go to the documentation of this file.
1
<?php
2
3
namespace
BristolSU\Support\Action\History
;
4
5
use
BristolSU\Support\Action\ActionResponse
;
6
use
Exception
;
7
use
Illuminate\Http\Response
;
8
9
trait
HasHistory
10
{
11
17
private
$actionInstanceId
;
18
24
private
$eventFields
;
25
31
private
$settings
;
32
38
public
function
setActionInstanceId
(
int
$actionInstanceId): void
39
{
40
$this->actionInstanceId = $actionInstanceId;
41
}
42
48
public
function
setEventFields
(array $eventFields): void
49
{
50
$this->eventFields = $eventFields;
51
}
52
58
public
function
setSettings
(array $settings): void
59
{
60
$this->
settings
= $settings;
61
}
62
69
public
function
saveHistory
(
ActionResponse
$response): void
70
{
71
if
($this->actionInstanceId === null){
72
throw
new
Exception
(
'The action instance ID must not be null'
);
73
}
74
75
ActionHistory::create([
76
'action_instance_id'
=> $this->actionInstanceId,
77
'event_fields'
=> ($this->eventFields ?? []),
78
'settings'
=> ($this->
settings
?? []),
79
'success'
=> $response->
getSuccess
(),
80
'message'
=> $response->
getMessage
()
81
]);
82
}
83
84
}
BristolSU\Support\Action\History\HasHistory\setEventFields
setEventFields(array $eventFields)
Definition:
HasHistory.php:48
BristolSU\Support\Action\History\HasHistory\$settings
$settings
Definition:
HasHistory.php:31
BristolSU\Support\Action\History\HasHistory\$eventFields
$eventFields
Definition:
HasHistory.php:24
function\settings
settings()
BristolSU\Support\Action\History\HasHistory\$actionInstanceId
$actionInstanceId
Definition:
HasHistory.php:17
BristolSU\Support\Action\History\HasHistory\saveHistory
saveHistory(ActionResponse $response)
Definition:
HasHistory.php:69
ActionResponse
BristolSU\Support\Action\ActionResponse\getMessage
getMessage()
Definition:
ActionResponse.php:33
HasHistory
BristolSU\Support\Action\ActionResponse
Definition:
ActionResponse.php:5
BristolSU\Support\Action\History\HasHistory\setActionInstanceId
setActionInstanceId(int $actionInstanceId)
Definition:
HasHistory.php:38
BristolSU\Support\Action\History
Definition:
ActionHistory.php:3
BristolSU\Support\Action\History\HasHistory\setSettings
setSettings(array $settings)
Definition:
HasHistory.php:58
BristolSU\Support\Action\ActionResponse\getSuccess
getSuccess()
Definition:
ActionResponse.php:52
Response
Exception
Generated by
1.8.13