Passed
Push — master ( 360e2b...e8c113 )
by Dark❶
04:59 queued 04:44
created

base_module   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 50
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 34 2
1
<?php
2
/**
3
 *
4
 * Member Avatar & Status [MAS]. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2018-2020, Dark❶ [dark1]
7
 * @license GNU General Public License, version 2 (GPL-2.0-only)
8
 *
9
 */
10
11
namespace dark1\memberavatarstatus\acp;
12
13
/**
14
 * Member Avatar & Status [MAS] ACP Module Base.
15
 */
16
class base_module
17
{
18
	public $page_title;
19
	public $tpl_name;
20
	public $u_action;
21
22
	/**
23
	 * Handle ACP module
24
	 *
25
	 * @param int    $id   The module ID
26
	 * @param string $mode The module mode
27
	 *
28
	 * @return void
29
	 * @access protected
30
	 * @throws \Exception
31
	 */
32
	protected function handle($id, $mode)
33
	{
34
		global $phpbb_container;
35
36
		// Normalize the Mode to Lowercase
37
		$mode = strtolower($mode);
38
39
		// check for valid Mode
40
		if (class_exists('dark1\memberavatarstatus\controller\acp_' . $mode))
41
		{
42
			// Get ACP controller for Mode
43
			$acp_controller = $phpbb_container->get('dark1.memberavatarstatus.controller.acp.' . $mode);
44
45
			// Load the display handle in our ACP controller
46
			$acp_controller->set_data($id, $mode, $this->u_action);
47
48
			// Get data from our ACP controller
49
			$acp_get_data = $acp_controller->get_data();
50
51
			// Load a template from adm/style for our ACP page
52
			$this->tpl_name = $acp_get_data['tpl_name'];
53
54
			// Set the page title for our ACP page
55
			$this->page_title = $acp_get_data['page_title'];
56
57
			// Load the setup in our ACP controller
58
			$acp_controller->setup();
59
60
			// Load the handle in our ACP controller
61
			$acp_controller->handle();
62
		}
63
		else
64
		{
65
			trigger_error('FORM_INVALID', E_USER_WARNING);
66
		}
67
	}
68
69
}
70