1 | <?php |
||||
2 | |||||
3 | namespace Jidaikobo\Kontiki\Controllers; |
||||
4 | |||||
5 | use Slim\App; |
||||
6 | use Psr\Http\Message\ResponseInterface as Response; |
||||
7 | use Psr\Http\Message\ServerRequestInterface as Request; |
||||
8 | use Slim\Views\PhpRenderer; |
||||
9 | |||||
10 | class AdminController |
||||
11 | { |
||||
12 | private PhpRenderer $view; |
||||
13 | |||||
14 | public function __construct(PhpRenderer $view) |
||||
15 | { |
||||
16 | $this->view = $view; |
||||
17 | } |
||||
18 | |||||
19 | public static function registerRoutes(App $app): void |
||||
20 | { |
||||
21 | $app->get('/kontiki-admin.js', AdminController::class . ':serveJs'); |
||||
22 | $app->get('/kontiki-admin.css', AdminController::class . ':serveCss'); |
||||
23 | $app->get('/favicon.ico', AdminController::class . ':serveFavicon'); |
||||
24 | } |
||||
25 | |||||
26 | /** |
||||
27 | * Serve the requested JavaScript file. |
||||
28 | * |
||||
29 | * @return Response |
||||
30 | */ |
||||
31 | public function serveJs(Request $request, Response $response): Response |
||||
0 ignored issues
–
show
|
|||||
32 | { |
||||
33 | $content = $this->view->fetch( |
||||
34 | 'js/kontiki-admin.js.php', |
||||
35 | [ |
||||
36 | 'skip_to_main_content' => __('skip_to_main_content'), |
||||
37 | 'skip_to_navigation' => __('skip_to_navigation'), |
||||
38 | 'publishing' => __('publishing'), |
||||
39 | 'reserved' => __('reserved'), |
||||
40 | 'expired' => __('expired'), |
||||
41 | 'do_publish' => __('do_publish', 'publish'), |
||||
42 | 'do_reserve' => __('do_reserve', 'reserve'), |
||||
43 | 'do_save_as_pending' => __('do_save_as_pending', 'save as pending'), |
||||
44 | 'do_save_as_draft' => __('do_save_as_draft', 'save as draft'), |
||||
45 | 'published_at' => __('published_at'), |
||||
46 | 'published_url' => __('published_url'), |
||||
47 | 'reserved_url' => __('reserved_url'), |
||||
48 | 'banned_url' => __('banned_url'), |
||||
49 | 'open_in_new_window' => __('open_in_new_window'), |
||||
50 | 'open_sidebar' => __('open_sidebar'), |
||||
51 | 'close_sidebar' => __('close_sidebar'), |
||||
52 | ] |
||||
53 | ); |
||||
54 | $response->getBody()->write($content); |
||||
55 | return $response->withHeader( |
||||
56 | 'Content-Type', |
||||
57 | 'application/javascript; charset=utf-8' |
||||
58 | )->withStatus(200); |
||||
0 ignored issues
–
show
The method
withStatus() does not exist on Psr\Http\Message\MessageInterface . It seems like you code against a sub-type of Psr\Http\Message\MessageInterface such as Psr\Http\Message\ResponseInterface or Slim\Psr7\Response .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
59 | } |
||||
60 | |||||
61 | /** |
||||
62 | * Serve the requested CSS file. |
||||
63 | * |
||||
64 | * @return Response |
||||
65 | */ |
||||
66 | public function serveCss(Request $request, Response $response): Response |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
67 | { |
||||
68 | $content = $this->view->fetch( |
||||
69 | 'css/kontiki-admin.css.php', |
||||
70 | [ |
||||
71 | 'color' => env('ADMIN_THEME_COLOR', '#ffffff'), |
||||
72 | 'bgcolor' => env('ADMIN_THEME_BGCOLOR', '#343a40') |
||||
73 | ] |
||||
74 | ); |
||||
75 | $response->getBody()->write($content); |
||||
76 | return $response->withHeader( |
||||
77 | 'Content-Type', |
||||
78 | 'text/css; charset=utf-8' |
||||
79 | )->withStatus(200); |
||||
80 | } |
||||
81 | |||||
82 | /** |
||||
83 | * Serve the requested favicon file. |
||||
84 | * |
||||
85 | * @return Response |
||||
86 | */ |
||||
87 | public function serveFavicon(Request $request, Response $response): Response |
||||
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
88 | { |
||||
89 | $faviconPath = env('PROJECT_PATH', '') . '/src/views/images/favicon.ico'; |
||||
90 | $content = file_get_contents($faviconPath); |
||||
91 | $response->getBody()->write($content); |
||||
92 | return $response |
||||
93 | ->withHeader('Content-Type', 'image/x-icon') |
||||
94 | ->withHeader('Cache-Control', 'public, max-age=86400') |
||||
95 | ->withStatus(200); |
||||
96 | } |
||||
97 | } |
||||
98 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.