-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDeleteInstanceTrait.php
More file actions
39 lines (33 loc) · 1.06 KB
/
DeleteInstanceTrait.php
File metadata and controls
39 lines (33 loc) · 1.06 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
<?php
declare(strict_types=1);
namespace Staffbase\plugins\sdk\RemoteCall;
trait DeleteInstanceTrait
{
/**
* Exit the script
*
* if a remote call was not handled by the user we die hard here
*/
protected function exitRemoteCall(): void
{
error_log("Warning: The exit procedure for a remote call was not properly handled.");
exit;
}
private function deleteInstance(string $instanceId, RemoteCallInterface $remoteCallHandler): never
{
if ($remoteCallHandler instanceof DeleteInstanceCallHandlerInterface) {
$result = $remoteCallHandler->deleteInstance($instanceId);
} else {
// we will accept unhandled calls with a warning
$result = true;
error_log("Warning: An instance deletion call for instance $instanceId was not handled.");
}
// finish the remote call
if ($result) {
$remoteCallHandler->exitSuccess();
} else {
$remoteCallHandler->exitFailure();
}
$this->exitRemoteCall();
}
}