Skip to content

Commit

Permalink
Workaround PSR errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iMattPro committed Dec 19, 2024
1 parent 1f249b0 commit e138659
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 52 deletions.
15 changes: 1 addition & 14 deletions controller/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
namespace phpbb\webpushnotifications\controller;

use phpbb\config\config;
use phpbb\exception\http_exception;
use phpbb\language\language;
use phpbb\path_helper;
use phpbb\user;
use phpbb\webpushnotifications\ext;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

class manifest
{
Expand All @@ -30,23 +27,18 @@ class manifest
/** @var path_helper */
protected $path_helper;

/** @var user */
protected $user;

/**
* Constructor for webpush controller
*
* @param config $config
* @param path_helper $path_helper
* @param language $language
* @param user $user
*/
public function __construct(config $config, language $language, path_helper $path_helper, user $user)
public function __construct(config $config, language $language, path_helper $path_helper)
{
$this->config = $config;
$this->path_helper = $path_helper;
$this->language = $language;
$this->user = $user;
}

/**
Expand All @@ -56,11 +48,6 @@ public function __construct(config $config, language $language, path_helper $pat
*/
public function handle(): JsonResponse
{
if ($this->user->data['is_bot'])
{
throw new http_exception(Response::HTTP_FORBIDDEN, 'NO_AUTH_OPERATION');
}

$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
$board_url = generate_board_url();

Expand Down
41 changes: 3 additions & 38 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
*
*/

use Symfony\Component\HttpFoundation\JsonResponse;
use phpbb\webpushnotifications\ext;

/**
* @ignore
**/
Expand All @@ -19,41 +16,9 @@
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

require_once($phpbb_root_path . 'ext/phpbb/webpushnotifications/controller/manifest.' . $phpEx);

/** @var \phpbb\path_helper $path_helper */
$path_helper = $phpbb_container->get('path_helper');

$board_path = $config['force_server_vars'] ? $config['script_path'] : $path_helper->get_web_root_path();
$board_url = generate_board_url();

// Emoji fixer-uppers
$sitename = ext::decode_entities($config['sitename'], ENT_QUOTES);
$pwa_short_name = ext::decode_entities($config['pwa_short_name'], ENT_QUOTES);

$manifest = [
'name' => $sitename,
'short_name' => $pwa_short_name ?: utf8_substr($sitename, 0, 12),
'display' => 'standalone',
'orientation' => 'portrait',
'dir' => $language->lang('DIRECTION'),
'start_url' => $board_path,
'scope' => $board_path,
];

if (!empty($config['pwa_icon_small']) && !empty($config['pwa_icon_large']))
{
$manifest['icons'] = [
[
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_small'],
'sizes' => '192x192',
'type' => 'image/png'
],
[
'src' => $board_url . '/' . ext::PWA_ICON_DIR . '/' . $config['pwa_icon_large'],
'sizes' => '512x512',
'type' => 'image/png'
]
];
}

$response = new JsonResponse($manifest);
$response->send();
echo (new \phpbb\webpushnotifications\controller\manifest($config, $language, $path_helper))->handle();

0 comments on commit e138659

Please sign in to comment.