1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Arcanedev\LaravelImpersonator\Contracts; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Interface Impersonator |
9
|
|
|
* |
10
|
|
|
* @author ARCANEDEV <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
interface Impersonator |
13
|
|
|
{ |
14
|
|
|
/* ----------------------------------------------------------------- |
15
|
|
|
| Getters & Setters |
16
|
|
|
| ----------------------------------------------------------------- |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get the session key. |
21
|
|
|
* |
22
|
|
|
* @return string |
23
|
|
|
*/ |
24
|
|
|
public function getSessionKey(): string; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get the session guard. |
28
|
|
|
* |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
public function getSessionGuard(): string; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the impersonator id. |
35
|
|
|
* |
36
|
|
|
* @return int|null |
37
|
|
|
*/ |
38
|
|
|
public function getImpersonatorId(): ?int; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get the impersonator guard. |
42
|
|
|
* |
43
|
|
|
* @return string|null |
44
|
|
|
*/ |
45
|
|
|
public function getImpersonatorGuard(): ?string; |
46
|
|
|
|
47
|
|
|
/* ----------------------------------------------------------------- |
48
|
|
|
| Main Methods |
49
|
|
|
| ----------------------------------------------------------------- |
50
|
|
|
*/ |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Start the impersonation. |
54
|
|
|
* |
55
|
|
|
* @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|mixed $impersonater |
56
|
|
|
* @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable|mixed $impersonated |
57
|
|
|
* @param string|null $guard |
58
|
|
|
* |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
|
|
public function start(Impersonatable $impersonater, Impersonatable $impersonated, $guard = null): bool; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Stop the impersonation. |
65
|
|
|
* |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function stop(): bool; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Clear the impersonation. |
72
|
|
|
*/ |
73
|
|
|
public function clear(): void; |
74
|
|
|
|
75
|
|
|
/* ----------------------------------------------------------------- |
76
|
|
|
| Check Methods |
77
|
|
|
| ----------------------------------------------------------------- |
78
|
|
|
*/ |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Check if the impersonations is enabled. |
82
|
|
|
* |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
|
|
public function isEnabled(): bool; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Check if the impersonator is impersonating. |
89
|
|
|
* |
90
|
|
|
* @return bool |
91
|
|
|
*/ |
92
|
|
|
public function isImpersonating(): bool; |
93
|
|
|
} |
94
|
|
|
|