Completed
Branch FET-9795-new-interfaces (4c886e)
by
unknown
353:56 queued 340:21
created

EED_Module   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 106
rs 10
wmc 9
lcom 1
cbo 3

7 Methods

Rating   Name   Duplication   Size   Complexity  
A reset() 0 3 1
A set_hooks() 0 1 1
A set_hooks_admin() 0 1 1
run() 0 1 ?
A __construct() 0 5 1
A get_instance() 0 7 4
A module_name() 0 3 1
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
/**
3
 * Event Espresso
4
 *
5
 * Event Registration and Management Plugin for WordPress
6
 *
7
 * @ package			Event Espresso
8
 * @ author 			Event Espresso
9
 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
 * @ link					http://www.eventespresso.com
12
 * @ version		 	4.0
13
 *
14
 * ------------------------------------------------------------------------
15
 *
16
 * EED_Module
17
 *
18
 * @package			Event Espresso
19
 * @subpackage 	/core/
20
 * @author				Brent Christensen
21
 *
22
 * ------------------------------------------------------------------------
23
 */
24
abstract class EED_Module extends EE_Configurable implements EventEspresso\core\interfaces\ResettableInterface {
25
26
	/**
27
	 * 	instance of the EED_Module object
28
	 * 	@access 	protected
29
	 *	@var 	EED_Module $_instance
30
	 */
31
	protected static $_instance = NULL;
32
33
	/**
34
	 * 	rendered output to be returned to WP
35
	 * 	@access 	protected
36
	 *	@var 	string $output
37
	 */
38
	protected $output = '';
39
40
	/**
41
	 * 	the current active espresso template theme
42
	 * 	@access 	protected
43
	 *	@var 	string $theme
44
	 */
45
	protected $theme = '';
46
47
48
49
	/**
50
	 * @return mixed
51
	 */
52
	public static function reset() {
53
		static::$_instance = null;
54
	}
55
56
57
58
	/**
59
	 * 	set_hooks - for hooking into EE Core, other modules, etc
60
	 *
61
	 *  @access 	public
62
	 *  @return 	void
63
	 */
64
	public static function set_hooks() {}
65
66
	/**
67
	 * 	set_hooks_admin - for hooking into EE Admin Core, other modules, etc
68
	 *
69
	 *  @access 	public
70
	 *  @return 	void
71
	 */
72
	public static function set_hooks_admin() {}
73
74
75
76
	/**
77
	 * 	run - initial module setup
78
	 * 	this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
79
	 *
80
	 *  @access 	public
81
	 *  @var 			WP $WP
82
	 *  @return 	void
83
	 */
84
	public abstract function run( $WP );
85
86
87
88
	/**
89
	 *    class constructor - can ONLY be instantiated by EE_Front_Controller
90
	 *
91
	 * @override default exception handling
92
	 * @access   public
93
	 * @return \EED_Module
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
94
	 */
95
	final public function __construct() {
96
		$this->theme = EE_Config::get_current_theme();
97
		$module_name = $this->module_name();
98
		EE_Registry::instance()->modules->{$module_name} = $this;
99
	}
100
101
102
103
	/**
104
	 * @param $module_name
105
	 * @return EED_Module
106
	 */
107
	protected static function get_instance( $module_name = '' ) {
108
		$module_name = ! empty( $module_name ) ? $module_name : get_called_class();
109
		if ( ! isset(  EE_Registry::instance()->modules->{$module_name} ) || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module ) {
110
			EE_Registry::instance()->add_module( $module_name );
111
		}
112
		return EE_Registry::instance()->get_module( $module_name );
113
	}
114
115
116
117
	/**
118
	 *    module_name
119
	 *
120
	 * @access    public
121
	 * @return    string
122
	 */
123
	public function module_name() {
124
		return get_class( $this );
125
	}
126
127
128
129
}
130
// End of file EED_Module.module.php
131