Skip to content

Commit e138659

Browse files
committed
Workaround PSR errors
1 parent 1f249b0 commit e138659

File tree

2 files changed

+4
-52
lines changed

2 files changed

+4
-52
lines changed

controller/manifest.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
namespace phpbb\webpushnotifications\controller;
1212

1313
use phpbb\config\config;
14-
use phpbb\exception\http_exception;
1514
use phpbb\language\language;
1615
use phpbb\path_helper;
17-
use phpbb\user;
1816
use phpbb\webpushnotifications\ext;
1917
use Symfony\Component\HttpFoundation\JsonResponse;
20-
use Symfony\Component\HttpFoundation\Response;
2118

2219
class manifest
2320
{
@@ -30,23 +27,18 @@ class manifest
3027
/** @var path_helper */
3128
protected $path_helper;
3229

33-
/** @var user */
34-
protected $user;
35-
3630
/**
3731
* Constructor for webpush controller
3832
*
3933
* @param config $config
4034
* @param path_helper $path_helper
4135
* @param language $language
42-
* @param user $user
4336
*/
44-
public function __construct(config $config, language $language, path_helper $path_helper, user $user)
37+
public function __construct(config $config, language $language, path_helper $path_helper)
4538
{
4639
$this->config = $config;
4740
$this->path_helper = $path_helper;
4841
$this->language = $language;
49-
$this->user = $user;
5042
}
5143

5244
/**
@@ -56,11 +48,6 @@ public function __construct(config $config, language $language, path_helper $pat
5648
*/
5749
public function handle(): JsonResponse
5850
{
59-
if ($this->user->data['is_bot'])
60-
{
61-
throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION');
62-
}
63-
6451
$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
6552
$board_url = generate_board_url();
6653

manifest.php

+3-38
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
*
99
*/
1010

11-
use Symfony\Component\HttpFoundation\JsonResponse;
12-
use phpbb\webpushnotifications\ext;
13-
1411
/**
1512
* @ignore
1613
**/
@@ -19,41 +16,9 @@
1916
$phpEx = substr(strrchr(__FILE__, '.'), 1);
2017
include($phpbb_root_path . 'common.' . $phpEx);
2118

19+
require_once($phpbb_root_path . 'ext/phpbb/webpushnotifications/controller/manifest.' . $phpEx);
20+
2221
/** @var \phpbb\path_helper $path_helper */
2322
$path_helper = $phpbb_container->get('path_helper');
2423

25-
$board_path = $config['force_server_vars'] ? $config['script_path'] : $path_helper->get_web_root_path();
26-
$board_url = generate_board_url();
27-
28-
// Emoji fixer-uppers
29-
$sitename = ext::decode_entities($config['sitename'], ENT_QUOTES);
30-
$pwa_short_name = ext::decode_entities($config['pwa_short_name'], ENT_QUOTES);
31-
32-
$manifest = [
33-
'name' => $sitename,
34-
'short_name' => $pwa_short_name ?: utf8_substr($sitename, 0, 12),
35-
'display' => 'standalone',
36-
'orientation' => 'portrait',
37-
'dir' => $language->lang('DIRECTION'),
38-
'start_url' => $board_path,
39-
'scope' => $board_path,
40-
];
41-
42-
if (!empty($config['pwa_icon_small']) && !empty($config['pwa_icon_large']))
43-
{
44-
$manifest['icons'] = [
45-
[
46-
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_small'],
47-
'sizes' => '192x192',
48-
'type' => 'image/png'
49-
],
50-
[
51-
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_large'],
52-
'sizes' => '512x512',
53-
'type' => 'image/png'
54-
]
55-
];
56-
}
57-
58-
$response = new JsonResponse($manifest);
59-
$response->send();
24+
echo (new \phpbb\webpushnotifications\controller\manifest($config, $language, $path_helper))->handle();

0 commit comments

Comments
 (0)