| 1 |
<?php namespace EmailLog\Core\UI; |
| 2 |
|
| 3 |
use EmailLog\Core\Loadie; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 6 |
|
| 7 |
/** |
| 8 |
* Admin UI Loader. |
| 9 |
* Loads and initializes all admin pages and components. |
| 10 |
* |
| 11 |
* @since 2.0 |
| 12 |
*/ |
| 13 |
class UILoader implements Loadie { |
| 14 |
|
| 15 |
/** |
| 16 |
* UI Component List. |
| 17 |
* |
| 18 |
* @var array |
| 19 |
*/ |
| 20 |
protected $components = array(); |
| 21 |
|
| 22 |
/** |
| 23 |
* List of Admin pages. |
| 24 |
* |
| 25 |
* @var \EmailLog\Core\UI\Page\BasePage[] |
| 26 |
*/ |
| 27 |
protected $pages = array(); |
| 28 |
|
| 29 |
/** |
| 30 |
* Load all components and setup hooks. |
| 31 |
* |
| 32 |
* @inheritdoc |
| 33 |
*/ |
| 34 |
public function load() { |
| 35 |
$this->initialize_components(); |
| 36 |
$this->initialize_pages(); |
| 37 |
|
| 38 |
foreach ( $this->components as $component ) { |
| 39 |
$component->load(); |
| 40 |
} |
| 41 |
|
| 42 |
foreach ( $this->pages as $page ) { |
| 43 |
$page->load(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Initialize UI component Objects. |
| 49 |
* |
| 50 |
* This method may be overwritten in tests. |
| 51 |
* |
| 52 |
* @access protected |
| 53 |
*/ |
| 54 |
protected function initialize_components() { |
| 55 |
$this->components['admin_ui_enhancer'] = new Component\AdminUIEnhancer(); |
| 56 |
$this->components['core_settings'] = new Setting\CoreSetting(); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Initialize Admin page Objects. |
| 61 |
* |
| 62 |
* This method may be overwritten in tests. |
| 63 |
* |
| 64 |
* @access protected |
| 65 |
*/ |
| 66 |
protected function initialize_pages() { |
| 67 |
$this->pages['log_list_page'] = new Page\LogListPage(); |
| 68 |
$this->pages['settings_page'] = new Page\SettingsPage(); |
| 69 |
$this->pages['addon_list_page'] = new Page\AddonListPage(); |
| 70 |
} |
| 71 |
} |
| 72 |
|