|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Imanghafoori\HeyMan\Reactions; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Auth\Access\AuthorizationException; |
|
6
|
|
|
use Imanghafoori\HeyMan\Chain; |
|
7
|
|
|
|
|
8
|
|
|
final class Reactions |
|
9
|
|
|
{ |
|
10
|
2 |
|
public function response(): Responder |
|
11
|
|
|
{ |
|
12
|
2 |
|
return new Responder($this); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
5 |
|
public function redirect(): Redirector |
|
16
|
|
|
{ |
|
17
|
5 |
|
return new Redirector($this); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
2 |
|
public function afterCalling($callback, array $parameters = []): self |
|
21
|
|
|
{ |
|
22
|
2 |
|
resolve(Chain::class)->addAfterCall($callback, $parameters); |
|
23
|
|
|
|
|
24
|
2 |
|
return $this; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
4 |
|
public function weThrowNew(string $exception, string $message = '') |
|
28
|
|
|
{ |
|
29
|
4 |
|
resolve(Chain::class)->commit(func_get_args(), 'exception'); |
|
30
|
4 |
|
} |
|
31
|
|
|
|
|
32
|
2 |
|
public function abort($code, string $message = '', array $headers = []) |
|
33
|
|
|
{ |
|
34
|
2 |
|
resolve(Chain::class)->commit(func_get_args(), __FUNCTION__); |
|
35
|
2 |
|
} |
|
36
|
|
|
|
|
37
|
1 |
|
public function weRespondFrom($callback, array $parameters = []) |
|
38
|
|
|
{ |
|
39
|
1 |
|
resolve(Chain::class)->commit(func_get_args(), 'respondFrom'); |
|
40
|
1 |
|
} |
|
41
|
|
|
|
|
42
|
81 |
|
public function weDenyAccess(string $message = '') |
|
43
|
|
|
{ |
|
44
|
81 |
|
resolve(Chain::class)->commit([AuthorizationException::class, $message], 'exception'); |
|
45
|
81 |
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function afterFiringEvent($event, $payload = [], $halt = false): self |
|
48
|
|
|
{ |
|
49
|
1 |
|
resolve(Chain::class)->eventFire($event, $payload, $halt); |
|
50
|
|
|
|
|
51
|
1 |
|
return $this; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
91 |
|
public function __destruct() |
|
55
|
|
|
{ |
|
56
|
91 |
|
resolve(Chain::class)->submitChainConfig(); |
|
57
|
91 |
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|