Completed
Push — master ( 46ce18...076ebc )
by Daniel
13:04
created

forum::handle()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2.004

Importance

Changes 4
Bugs 4 Features 0
Metric Value
c 4
b 4
f 0
dl 0
loc 26
ccs 9
cts 10
cp 0.9
rs 8.8571
cc 2
eloc 11
nc 2
nop 0
crap 2.004
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\controller;
11
12
class forum
13
{
14
	/** @var \phpbb\config\config */
15
	protected $config;
16
17
	/** @var \phpbb\controller\helper */
18
	protected $helper;
19
20
	/** @var \phpbb\template\template */
21
	protected $template;
22
23
	/** @var \phpbb\user */
24
	protected $user;
25
26
	/** @var string phpBB root path */
27
	protected $phpbb_root_path;
28
29
	/** @var string phpEx */
30
	protected $php_ext;
31
32
	/**
33
	 * Constructor
34
	 *
35
	 * @param \phpbb\config\config			$config			Config object
36
	 * @param \phpbb\controller\helper		$helper			Controller Helper object
37
	 * @param \phpbb\template\template		$template		Template object
38
	 * @param \phpbb\user					$user			User object
39
	 * @param string						$root_path		phpBB root path
40
	 * @param string						$php_ext		phpEx
41
	 */
42 1
	public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\user $user, $root_path, $php_ext)
43
	{
44 1
		$this->config = $config;
45 1
		$this->helper = $helper;
46 1
		$this->template = $template;
47 1
		$this->user = $user;
48 1
		$this->phpbb_root_path = $root_path;
49 1
		$this->php_ext = $php_ext;
50 1
	}
51
52
	/**
53
	 * @return \Symfony\Component\HttpFoundation\Response
54
	 */
55 1
	public function handle()
56
	{
57 1
		/**
58 1
		 * This is ugly but the only way I could find
59
		 * to fix relative paths for forum images
60
		 */
61
		global $phpbb_root_path;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
62 1
		$phpbb_root_path = generate_board_url() . '/';
63
64 1
		if (!function_exists('display_forums'))
65 1
		{
66 1
			include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); // @codeCoverageIgnore
67 1
		}
68
69 1
		display_forums('', $this->config['load_moderators']);
70
71
		// restore phpbb_root_path
72
		$phpbb_root_path = $this->phpbb_root_path;
73
74
		$this->template->assign_block_vars('navlinks', array(
75
			'FORUM_NAME'	=> $this->user->lang('FORUM'),
76
			'U_VIEW_FORUM'	=> $this->helper->route('blitze_sitemaker_forum')
77
		));
78
79
		return $this->helper->render('index_body.html', $this->user->lang('FORUM_INDEX'));
80
	}
81
}
82