1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Pterodactyl - Panel |
4
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>. |
5
|
|
|
* |
6
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
7
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
8
|
|
|
* in the Software without restriction, including without limitation the rights |
9
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
11
|
|
|
* furnished to do so, subject to the following conditions: |
12
|
|
|
* |
13
|
|
|
* The above copyright notice and this permission notice shall be included in all |
14
|
|
|
* copies or substantial portions of the Software. |
15
|
|
|
* |
16
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
20
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
21
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
22
|
|
|
* SOFTWARE. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace Pterodactyl\Observers; |
26
|
|
|
|
27
|
|
|
use Carbon; |
28
|
|
|
use Pterodactyl\Events; |
29
|
|
|
use Pterodactyl\Models\Server; |
30
|
|
|
use Pterodactyl\Jobs\DeleteServer; |
31
|
|
|
use Pterodactyl\Jobs\SuspendServer; |
32
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
33
|
|
|
|
34
|
|
|
class ServerObserver |
35
|
|
|
{ |
36
|
|
|
use DispatchesJobs; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Listen to the Server deleted event. |
40
|
|
|
* |
41
|
|
|
* @param Server $server [description] |
42
|
|
|
* @return [type] [description] |
|
|
|
|
43
|
|
|
*/ |
44
|
|
|
public function creating(Server $server) |
45
|
|
|
{ |
46
|
|
|
event(new Events\Server\Creating($server)); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Listen to the Server deleted event. |
51
|
|
|
* |
52
|
|
|
* @param Server $server [description] |
53
|
|
|
* @return [type] [description] |
|
|
|
|
54
|
|
|
*/ |
55
|
|
|
public function created(Server $server) |
56
|
|
|
{ |
57
|
|
|
event(new Events\Server\Created($server)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Listen to the Server deleted event. |
62
|
|
|
* |
63
|
|
|
* @param Server $server [description] |
64
|
|
|
* @return [type] [description] |
|
|
|
|
65
|
|
|
*/ |
66
|
|
|
public function deleting(Server $server) |
67
|
|
|
{ |
68
|
|
|
event(new Events\Server\Deleting($server)); |
69
|
|
|
|
70
|
|
|
$this->dispatch((new SuspendServer($server->id))->onQueue(env('QUEUE_HIGH', 'high'))); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Listen to the Server deleted event. |
75
|
|
|
* |
76
|
|
|
* @param Server $server [description] |
77
|
|
|
* @return [type] [description] |
|
|
|
|
78
|
|
|
*/ |
79
|
|
|
public function deleted(Server $server) |
80
|
|
|
{ |
81
|
|
|
event(new Events\Server\Deleted($server)); |
82
|
|
|
|
83
|
|
|
$this->dispatch( |
84
|
|
|
(new DeleteServer($server->id)) |
|
|
|
|
85
|
|
|
->delay(Carbon::now()->addMinutes(env('APP_DELETE_MINUTES', 10))) |
86
|
|
|
->onQueue(env('QUEUE_STANDARD', 'standard')) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.