Completed
Push — master ( 5841c7...d52f43 )
by Sudar
03:55
created

UIManager::load()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 2
b 0
f 0
nc 4
nop 0
dl 0
loc 12
ccs 0
cts 10
cp 0
crap 12
rs 9.4285
1
<?php namespace EmailLog\Core\UI;
2
3
use EmailLog\Core\UI\Component\PluginListEnhancer;
4
5
/**
6
 * Admin UI Manager.
7
 *
8
 * @since 2.0
9
 */
10
class UIManager {
11
12
	/**
13
	 * @var string Plugin filename.
14
	 */
15
	protected $plugin_file;
16
17
	/**
18
	 * @var array UI Component List.
19
	 */
20
	protected $components = array();
21
22
	/**
23
	 * @var array Admin pages.
24
	 */
25
	protected $pages = array();
26
27
	/**
28
	 * Initialize the plugin.
29
	 */
30 2
	public function __construct( $file ) {
31 2
		$this->plugin_file = $file;
32 2
	}
33
34
	/**
35
	 * Load all components and setup hooks.
36
	 */
37
	public function load() {
38
		$this->initialize_components();
39
		$this->initialize_pages();
40
41
		foreach ( $this->components as $component ) {
42
			$component->load();
43
		}
44
45
		foreach ( $this->pages as $page ) {
46
			$page->load();
47
		}
48
	}
49
50
	/**
51
	 * Initialize UI component Objects.
52
	 *
53
	 * This method may be overwritten in tests.
54
	 *
55
	 * @access protected
56
	 */
57
	protected function initialize_components() {
58
		$this->components['plugin_list_enhancer'] = new PluginListEnhancer( $this->plugin_file );
59
	}
60
61
	/**
62
	 * Initialize Admin page Objects.
63
	 *
64
	 * This method may be overwritten in tests.
65
	 *
66
	 * @access protected
67
	 */
68
	protected function initialize_pages() {
69
		$this->pages['log_list_page']   = new Page\LogListPage( $this->plugin_file );
70
		$this->pages['addon_list_page'] = new Page\AddonListPage( $this->plugin_file );
71
	}
72
}