1 | <?php |
||
13 | class TerminalController extends Controller |
||
14 | { |
||
15 | /** |
||
16 | * $request. |
||
17 | * |
||
18 | * @var \Illuminate\Http\Request |
||
19 | */ |
||
20 | protected $request; |
||
21 | |||
22 | /** |
||
23 | * $responseFactory. |
||
24 | * |
||
25 | * @var \Illuminate\Contracts\Routing\ResponseFactory |
||
26 | */ |
||
27 | protected $responseFactory; |
||
28 | |||
29 | /** |
||
30 | * __construct. |
||
31 | * |
||
32 | * @param \Illuminate\Http\Request $request |
||
33 | * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory |
||
34 | */ |
||
35 | 2 | public function __construct(Request $request, ResponseFactory $responseFactory) |
|
40 | |||
41 | /** |
||
42 | * index. |
||
43 | * |
||
44 | * @param \Recca0120\Terminal\Kernel $kernel |
||
45 | * @param string $view |
||
46 | * @return \Illuminate\Http\Response |
||
47 | */ |
||
48 | 1 | public function index(Kernel $kernel, $view = 'index') |
|
49 | { |
||
50 | 1 | $token = null; |
|
51 | 1 | if ($this->request->hasSession() === true) { |
|
52 | 1 | $token = $this->request->session()->token(); |
|
53 | 1 | } |
|
54 | |||
55 | 1 | $kernel->call('list --ansi'); |
|
56 | 1 | $options = json_encode(array_merge($kernel->getConfig(), [ |
|
57 | 1 | 'csrfToken' => $token, |
|
58 | 1 | 'helpInfo' => $kernel->output(), |
|
59 | 1 | ])); |
|
60 | 1 | $id = ($view === 'panel') ? Str::random(30) : null; |
|
61 | |||
62 | 1 | return $this->responseFactory->view('terminal::'.$view, compact('options', 'id')); |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * rpc response. |
||
67 | * |
||
68 | * @param \Recca0120\Terminal\Kernel $kernel |
||
69 | * @return \Illuminate\Http\JsonResponse |
||
70 | */ |
||
71 | 1 | public function endpoint(Kernel $kernel) |
|
89 | |||
90 | /** |
||
91 | * media. |
||
92 | * |
||
93 | * @param \Illuminate\Filesystem\Filesystem $files |
||
94 | * @param string $file |
||
95 | * @return \Illuminate\Http\Response |
||
96 | */ |
||
97 | public function media(Filesystem $files, $file) |
||
124 | } |
||
125 |