Completed
Pull Request — master (#331)
by Darren
19:27
created
core/services/editor/BlockRegistrationManager.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -36,144 +36,144 @@
 block discarded – undo
36 36
 class BlockRegistrationManager extends BlockManager
37 37
 {
38 38
 
39
-    /**
40
-     * @var BlockAssetManagerCollection $block_asset_manager_collection
41
-     */
42
-    protected $block_asset_manager_collection;
43
-
44
-
45
-    /**
46
-     * BlockRegistrationManager constructor.
47
-     *
48
-     * @param BlockAssetManagerCollection $block_asset_manager_collection
49
-     * @param BlockCollection             $blocks
50
-     * @param RequestInterface            $request
51
-     */
52
-    public function __construct(
53
-        BlockAssetManagerCollection $block_asset_manager_collection,
54
-        BlockCollection $blocks,
55
-        RequestInterface $request
56
-    ) {
57
-        $this->block_asset_manager_collection = $block_asset_manager_collection;
58
-        parent::__construct($blocks, $request);
59
-    }
60
-
61
-
62
-    /**
63
-     *  Returns the name of a hookpoint to be used to call initialize()
64
-     *
65
-     * @return string
66
-     */
67
-    public function initHook()
68
-    {
69
-        return 'AHEE__EE_System__core_loaded_and_ready';
70
-    }
71
-
72
-
73
-    /**
74
-     * Perform any early setup required for block editors to functions
75
-     *
76
-     * @return void
77
-     * @throws Exception
78
-     */
79
-    public function initialize()
80
-    {
81
-        $this->initializeBlocks();
82
-        add_action('AHEE__EE_System__initialize', array($this, 'registerBlocks'));
83
-    }
84
-
85
-
86
-    /**
87
-     * @return CollectionInterface|BlockInterface[]
88
-     * @throws ReflectionException
89
-     * @throws InvalidArgumentException
90
-     * @throws EE_Error
91
-     * @throws InvalidClassException
92
-     * @throws InvalidDataTypeException
93
-     * @throws InvalidEntityException
94
-     * @throws InvalidFilePathException
95
-     * @throws InvalidIdentifierException
96
-     * @throws InvalidInterfaceException
97
-     */
98
-    protected function populateBlockCollection()
99
-    {
100
-        $loader = new CollectionLoader(
101
-            new CollectionDetails(
102
-                // collection name
103
-                'shortcodes',
104
-                // collection interface
105
-                'EventEspresso\core\domain\entities\editor\BlockInterface',
106
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
107
-                apply_filters(
108
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
109
-                    array(
110
-                        // 'EventEspresso\core\domain\entities\editor\blocks\common',
111
-                        // 'EventEspresso\core\domain\entities\editor\blocks\editor',
112
-                        // 'EventEspresso\core\domain\entities\editor\blocks\widgets',
113
-                    )
114
-                ),
115
-                // filepaths to classes to add
116
-                array(),
117
-                // file mask to use if parsing folder for files to add
118
-                '',
119
-                // what to use as identifier for collection entities
120
-                // using CLASS NAME prevents duplicates (works like a singleton)
121
-                CollectionDetails::ID_CLASS_NAME
122
-            ),
123
-            $this->blocks
124
-        );
125
-        return $loader->getCollection();
126
-    }
127
-
128
-
129
-    /**
130
-     * populates the BlockCollection and calls initialize() on all installed blocks
131
-     *
132
-     * @return void
133
-     * @throws Exception
134
-     */
135
-    public function initializeBlocks()
136
-    {
137
-        try {
138
-            $this->populateBlockCollection();
139
-            // cycle thru block loaders and initialize each loader
140
-            foreach ($this->blocks as $block) {
141
-                $block->initialize();
142
-                if (! $this->block_asset_manager_collection->has($block->assetManager())) {
143
-                    $this->block_asset_manager_collection->add($block->assetManager());
144
-                    $block->assetManager()->setAssetHandles();
145
-                }
146
-            }
147
-        } catch (Exception $exception) {
148
-            new ExceptionStackTraceDisplay($exception);
149
-        }
150
-    }
151
-
152
-
153
-    /**
154
-     * calls registerBlock() and load assets for all installed blocks
155
-     *
156
-     * @return void
157
-     * @throws Exception
158
-     */
159
-    public function registerBlocks()
160
-    {
161
-        try {
162
-            // cycle thru block loader folders
163
-            foreach ($this->blocks as $block) {
164
-                // perform any setup required for the block
165
-                $block_type = $block->registerBlock();
166
-                if (! $block_type instanceof WP_Block_Type) {
167
-                    throw new InvalidEntityException($block_type, 'WP_Block_Type');
168
-                }
169
-                do_action(
170
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
171
-                    $block,
172
-                    $block_type
173
-                );
174
-            }
175
-        } catch (Exception $exception) {
176
-            new ExceptionStackTraceDisplay($exception);
177
-        }
178
-    }
39
+	/**
40
+	 * @var BlockAssetManagerCollection $block_asset_manager_collection
41
+	 */
42
+	protected $block_asset_manager_collection;
43
+
44
+
45
+	/**
46
+	 * BlockRegistrationManager constructor.
47
+	 *
48
+	 * @param BlockAssetManagerCollection $block_asset_manager_collection
49
+	 * @param BlockCollection             $blocks
50
+	 * @param RequestInterface            $request
51
+	 */
52
+	public function __construct(
53
+		BlockAssetManagerCollection $block_asset_manager_collection,
54
+		BlockCollection $blocks,
55
+		RequestInterface $request
56
+	) {
57
+		$this->block_asset_manager_collection = $block_asset_manager_collection;
58
+		parent::__construct($blocks, $request);
59
+	}
60
+
61
+
62
+	/**
63
+	 *  Returns the name of a hookpoint to be used to call initialize()
64
+	 *
65
+	 * @return string
66
+	 */
67
+	public function initHook()
68
+	{
69
+		return 'AHEE__EE_System__core_loaded_and_ready';
70
+	}
71
+
72
+
73
+	/**
74
+	 * Perform any early setup required for block editors to functions
75
+	 *
76
+	 * @return void
77
+	 * @throws Exception
78
+	 */
79
+	public function initialize()
80
+	{
81
+		$this->initializeBlocks();
82
+		add_action('AHEE__EE_System__initialize', array($this, 'registerBlocks'));
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return CollectionInterface|BlockInterface[]
88
+	 * @throws ReflectionException
89
+	 * @throws InvalidArgumentException
90
+	 * @throws EE_Error
91
+	 * @throws InvalidClassException
92
+	 * @throws InvalidDataTypeException
93
+	 * @throws InvalidEntityException
94
+	 * @throws InvalidFilePathException
95
+	 * @throws InvalidIdentifierException
96
+	 * @throws InvalidInterfaceException
97
+	 */
98
+	protected function populateBlockCollection()
99
+	{
100
+		$loader = new CollectionLoader(
101
+			new CollectionDetails(
102
+				// collection name
103
+				'shortcodes',
104
+				// collection interface
105
+				'EventEspresso\core\domain\entities\editor\BlockInterface',
106
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
107
+				apply_filters(
108
+					'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
109
+					array(
110
+						// 'EventEspresso\core\domain\entities\editor\blocks\common',
111
+						// 'EventEspresso\core\domain\entities\editor\blocks\editor',
112
+						// 'EventEspresso\core\domain\entities\editor\blocks\widgets',
113
+					)
114
+				),
115
+				// filepaths to classes to add
116
+				array(),
117
+				// file mask to use if parsing folder for files to add
118
+				'',
119
+				// what to use as identifier for collection entities
120
+				// using CLASS NAME prevents duplicates (works like a singleton)
121
+				CollectionDetails::ID_CLASS_NAME
122
+			),
123
+			$this->blocks
124
+		);
125
+		return $loader->getCollection();
126
+	}
127
+
128
+
129
+	/**
130
+	 * populates the BlockCollection and calls initialize() on all installed blocks
131
+	 *
132
+	 * @return void
133
+	 * @throws Exception
134
+	 */
135
+	public function initializeBlocks()
136
+	{
137
+		try {
138
+			$this->populateBlockCollection();
139
+			// cycle thru block loaders and initialize each loader
140
+			foreach ($this->blocks as $block) {
141
+				$block->initialize();
142
+				if (! $this->block_asset_manager_collection->has($block->assetManager())) {
143
+					$this->block_asset_manager_collection->add($block->assetManager());
144
+					$block->assetManager()->setAssetHandles();
145
+				}
146
+			}
147
+		} catch (Exception $exception) {
148
+			new ExceptionStackTraceDisplay($exception);
149
+		}
150
+	}
151
+
152
+
153
+	/**
154
+	 * calls registerBlock() and load assets for all installed blocks
155
+	 *
156
+	 * @return void
157
+	 * @throws Exception
158
+	 */
159
+	public function registerBlocks()
160
+	{
161
+		try {
162
+			// cycle thru block loader folders
163
+			foreach ($this->blocks as $block) {
164
+				// perform any setup required for the block
165
+				$block_type = $block->registerBlock();
166
+				if (! $block_type instanceof WP_Block_Type) {
167
+					throw new InvalidEntityException($block_type, 'WP_Block_Type');
168
+				}
169
+				do_action(
170
+					'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
171
+					$block,
172
+					$block_type
173
+				);
174
+			}
175
+		} catch (Exception $exception) {
176
+			new ExceptionStackTraceDisplay($exception);
177
+		}
178
+	}
179 179
 }
Please login to merge, or discard this patch.
core/domain/entities/editor/Block.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -20,216 +20,216 @@
 block discarded – undo
20 20
 abstract class Block implements BlockInterface
21 21
 {
22 22
 
23
-    /**
24
-     * BlockAssetManager that this editor block uses for asset registration
25
-     *
26
-     * @var BlockAssetManagerInterface $block_asset_manager
27
-     */
28
-    protected $block_asset_manager;
29
-
30
-    /**
31
-     * @var array $attributes
32
-     */
33
-    private $attributes;
34
-
35
-    /**
36
-     * If set to true, then the block will render its content client side
37
-     * If false, then the block will render its content server side using the renderBlock() method
38
-     *
39
-     * @var bool $dynamic
40
-     */
41
-    private $dynamic = false;
42
-
43
-    /**
44
-     * @var string $block_type
45
-     */
46
-    private $block_type;
47
-
48
-    /**
49
-     * @var array $supported_post_types
50
-     */
51
-    private $supported_post_types;
52
-
53
-    /**
54
-     * @var WP_Block_Type $wp_block_type
55
-     */
56
-    private $wp_block_type;
57
-
58
-
59
-    /**
60
-     * BlockLoader constructor.
61
-     *
62
-     * @param BlockAssetManagerInterface $block_asset_manager
63
-     */
64
-    public function __construct(BlockAssetManagerInterface $block_asset_manager)
65
-    {
66
-        $this->block_asset_manager = $block_asset_manager;
67
-    }
68
-
69
-
70
-    /**
71
-     * @return string
72
-     */
73
-    public function blockType()
74
-    {
75
-        return $this->block_type;
76
-    }
77
-
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    public function namespacedBlockType()
83
-    {
84
-        return self::NAME_SPACE . '/' . $this->block_type;
85
-    }
86
-
87
-
88
-    /**
89
-     * @param string $block_type
90
-     */
91
-    protected function setBlockType($block_type)
92
-    {
93
-        $this->block_type = $block_type;
94
-    }
95
-
96
-
97
-    /**
98
-     * BlockAssetManager that this editor block uses for asset registration
99
-     *
100
-     * @return BlockAssetManagerInterface
101
-     */
102
-    public function assetManager()
103
-    {
104
-        return $this->block_asset_manager;
105
-    }
106
-
107
-
108
-    /**
109
-     * @param WP_Block_Type $wp_block_type
110
-     */
111
-    protected function setWpBlockType($wp_block_type)
112
-    {
113
-        $this->wp_block_type = $wp_block_type;
114
-    }
115
-
116
-
117
-    /**
118
-     * @param array $supported_post_types
119
-     */
120
-    protected function setSupportedPostTypes(array $supported_post_types)
121
-    {
122
-        $this->supported_post_types = $supported_post_types;
123
-    }
124
-
125
-
126
-    /**
127
-     * @return array
128
-     */
129
-    public function attributes()
130
-    {
131
-        return $this->attributes;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param array $attributes
137
-     */
138
-    public function setAttributes(array $attributes)
139
-    {
140
-        $this->attributes = $attributes;
141
-    }
142
-
143
-
144
-    /**
145
-     * @return bool
146
-     */
147
-    public function isDynamic()
148
-    {
149
-        return $this->dynamic;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param bool $dynamic
155
-     */
156
-    public function setDynamic($dynamic = true)
157
-    {
158
-        $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN);
159
-    }
160
-
161
-
162
-    /**
163
-     * Registers the Editor Block with WP core;
164
-     * Returns the registered block type on success, or false on failure.
165
-     *
166
-     * @return WP_Block_Type|false
167
-     */
168
-    public function registerBlock()
169
-    {
170
-        $args = array(
171
-            'attributes'    => $this->attributes(),
172
-            'editor_script' => $this->block_asset_manager->getEditorScriptHandle(),
173
-            'editor_style'  => $this->block_asset_manager->getEditorStyleHandle(),
174
-            'script'        => $this->block_asset_manager->getScriptHandle(),
175
-            'style'         => $this->block_asset_manager->getStyleHandle(),
176
-        );
177
-        if (! $this->isDynamic()) {
178
-            $args['render_callback'] = $this->renderBlock();
179
-        }
180
-        $wp_block_type = register_block_type(
181
-            new WP_Block_Type(
182
-                $this->namespacedBlockType(),
183
-                $args
184
-            )
185
-        );
186
-        $this->setWpBlockType($wp_block_type);
187
-        return $wp_block_type;
188
-    }
189
-
190
-
191
-    /**
192
-     * @return WP_Block_Type|false The registered block type on success, or false on failure.
193
-     */
194
-    public function unRegisterBlock()
195
-    {
196
-        return unregister_block_type($this->namespacedBlockType());
197
-    }
198
-
199
-
200
-    /**
201
-     * returns true if the block type applies for the supplied post type
202
-     * and should be added to that post type's editor
203
-     *
204
-     * @param string $post_type
205
-     * @return boolean
206
-     */
207
-    public function appliesToPostType($post_type)
208
-    {
209
-        return in_array($post_type, $this->supported_post_types, true);
210
-    }
211
-
212
-
213
-    /**
214
-     * @return array
215
-     */
216
-    public function getEditorContainer()
217
-    {
218
-        return array(
219
-            $this->namespacedBlockType(),
220
-            array(),
221
-        );
222
-    }
223
-
224
-
225
-    /**
226
-     * returns the rendered HTML for the block
227
-     *
228
-     * @param array $attributes
229
-     * @return string
230
-     */
231
-    public function renderBlock(array $attributes = array())
232
-    {
233
-        return '';
234
-    }
23
+	/**
24
+	 * BlockAssetManager that this editor block uses for asset registration
25
+	 *
26
+	 * @var BlockAssetManagerInterface $block_asset_manager
27
+	 */
28
+	protected $block_asset_manager;
29
+
30
+	/**
31
+	 * @var array $attributes
32
+	 */
33
+	private $attributes;
34
+
35
+	/**
36
+	 * If set to true, then the block will render its content client side
37
+	 * If false, then the block will render its content server side using the renderBlock() method
38
+	 *
39
+	 * @var bool $dynamic
40
+	 */
41
+	private $dynamic = false;
42
+
43
+	/**
44
+	 * @var string $block_type
45
+	 */
46
+	private $block_type;
47
+
48
+	/**
49
+	 * @var array $supported_post_types
50
+	 */
51
+	private $supported_post_types;
52
+
53
+	/**
54
+	 * @var WP_Block_Type $wp_block_type
55
+	 */
56
+	private $wp_block_type;
57
+
58
+
59
+	/**
60
+	 * BlockLoader constructor.
61
+	 *
62
+	 * @param BlockAssetManagerInterface $block_asset_manager
63
+	 */
64
+	public function __construct(BlockAssetManagerInterface $block_asset_manager)
65
+	{
66
+		$this->block_asset_manager = $block_asset_manager;
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return string
72
+	 */
73
+	public function blockType()
74
+	{
75
+		return $this->block_type;
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	public function namespacedBlockType()
83
+	{
84
+		return self::NAME_SPACE . '/' . $this->block_type;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @param string $block_type
90
+	 */
91
+	protected function setBlockType($block_type)
92
+	{
93
+		$this->block_type = $block_type;
94
+	}
95
+
96
+
97
+	/**
98
+	 * BlockAssetManager that this editor block uses for asset registration
99
+	 *
100
+	 * @return BlockAssetManagerInterface
101
+	 */
102
+	public function assetManager()
103
+	{
104
+		return $this->block_asset_manager;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @param WP_Block_Type $wp_block_type
110
+	 */
111
+	protected function setWpBlockType($wp_block_type)
112
+	{
113
+		$this->wp_block_type = $wp_block_type;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param array $supported_post_types
119
+	 */
120
+	protected function setSupportedPostTypes(array $supported_post_types)
121
+	{
122
+		$this->supported_post_types = $supported_post_types;
123
+	}
124
+
125
+
126
+	/**
127
+	 * @return array
128
+	 */
129
+	public function attributes()
130
+	{
131
+		return $this->attributes;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param array $attributes
137
+	 */
138
+	public function setAttributes(array $attributes)
139
+	{
140
+		$this->attributes = $attributes;
141
+	}
142
+
143
+
144
+	/**
145
+	 * @return bool
146
+	 */
147
+	public function isDynamic()
148
+	{
149
+		return $this->dynamic;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param bool $dynamic
155
+	 */
156
+	public function setDynamic($dynamic = true)
157
+	{
158
+		$this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN);
159
+	}
160
+
161
+
162
+	/**
163
+	 * Registers the Editor Block with WP core;
164
+	 * Returns the registered block type on success, or false on failure.
165
+	 *
166
+	 * @return WP_Block_Type|false
167
+	 */
168
+	public function registerBlock()
169
+	{
170
+		$args = array(
171
+			'attributes'    => $this->attributes(),
172
+			'editor_script' => $this->block_asset_manager->getEditorScriptHandle(),
173
+			'editor_style'  => $this->block_asset_manager->getEditorStyleHandle(),
174
+			'script'        => $this->block_asset_manager->getScriptHandle(),
175
+			'style'         => $this->block_asset_manager->getStyleHandle(),
176
+		);
177
+		if (! $this->isDynamic()) {
178
+			$args['render_callback'] = $this->renderBlock();
179
+		}
180
+		$wp_block_type = register_block_type(
181
+			new WP_Block_Type(
182
+				$this->namespacedBlockType(),
183
+				$args
184
+			)
185
+		);
186
+		$this->setWpBlockType($wp_block_type);
187
+		return $wp_block_type;
188
+	}
189
+
190
+
191
+	/**
192
+	 * @return WP_Block_Type|false The registered block type on success, or false on failure.
193
+	 */
194
+	public function unRegisterBlock()
195
+	{
196
+		return unregister_block_type($this->namespacedBlockType());
197
+	}
198
+
199
+
200
+	/**
201
+	 * returns true if the block type applies for the supplied post type
202
+	 * and should be added to that post type's editor
203
+	 *
204
+	 * @param string $post_type
205
+	 * @return boolean
206
+	 */
207
+	public function appliesToPostType($post_type)
208
+	{
209
+		return in_array($post_type, $this->supported_post_types, true);
210
+	}
211
+
212
+
213
+	/**
214
+	 * @return array
215
+	 */
216
+	public function getEditorContainer()
217
+	{
218
+		return array(
219
+			$this->namespacedBlockType(),
220
+			array(),
221
+		);
222
+	}
223
+
224
+
225
+	/**
226
+	 * returns the rendered HTML for the block
227
+	 *
228
+	 * @param array $attributes
229
+	 * @return string
230
+	 */
231
+	public function renderBlock(array $attributes = array())
232
+	{
233
+		return '';
234
+	}
235 235
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function namespacedBlockType()
83 83
     {
84
-        return self::NAME_SPACE . '/' . $this->block_type;
84
+        return self::NAME_SPACE.'/'.$this->block_type;
85 85
     }
86 86
 
87 87
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             'script'        => $this->block_asset_manager->getScriptHandle(),
175 175
             'style'         => $this->block_asset_manager->getStyleHandle(),
176 176
         );
177
-        if (! $this->isDynamic()) {
177
+        if ( ! $this->isDynamic()) {
178 178
             $args['render_callback'] = $this->renderBlock();
179 179
         }
180 180
         $wp_block_type = register_block_type(
Please login to merge, or discard this patch.
core/domain/entities/editor/BlockInterface.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -22,70 +22,70 @@
 block discarded – undo
22 22
 interface BlockInterface
23 23
 {
24 24
 
25
-    const NAME_SPACE = 'eventespresso';
26
-
27
-    /**
28
-     * Perform any early setup required by the block
29
-     * including setting the block type and supported post types
30
-     *
31
-     * @return void
32
-     */
33
-    public function initialize();
34
-
35
-
36
-    /**
37
-     * @return string
38
-     */
39
-    public function blockType();
40
-
41
-
42
-    /**
43
-     * AssetRegister that this editor block uses for asset registration
44
-     *
45
-     * @return BlockAssetManagerInterface
46
-     */
47
-    public function assetManager();
48
-
49
-
50
-    /**
51
-     * Registers the Editor Block with WP core;
52
-     * Returns the registered block type on success, or false on failure.
53
-     *
54
-     * @return WP_Block_Type|false
55
-     */
56
-    public function registerBlock();
57
-
58
-
59
-    /**
60
-     * Un-registers the Editor Block with WP core;
61
-     * Returns the registered block type on success, or false on failure.
62
-     *
63
-     * @return WP_Block_Type|false
64
-     */
65
-    public function unRegisterBlock();
66
-
67
-
68
-    /**
69
-     * returns true if the block type applies for the supplied post type
70
-     * and should be added to that post type's editor
71
-     *
72
-     * @param string $post_type
73
-     * @return boolean
74
-     */
75
-    public function appliesToPostType($post_type);
76
-
77
-
78
-    /**
79
-     * @return array
80
-     */
81
-    public function getEditorContainer();
82
-
83
-
84
-    /**
85
-     * returns the rendered HTML for the block
86
-     *
87
-     * @param array $attributes
88
-     * @return string
89
-     */
90
-    public function renderBlock(array $attributes = array());
25
+	const NAME_SPACE = 'eventespresso';
26
+
27
+	/**
28
+	 * Perform any early setup required by the block
29
+	 * including setting the block type and supported post types
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function initialize();
34
+
35
+
36
+	/**
37
+	 * @return string
38
+	 */
39
+	public function blockType();
40
+
41
+
42
+	/**
43
+	 * AssetRegister that this editor block uses for asset registration
44
+	 *
45
+	 * @return BlockAssetManagerInterface
46
+	 */
47
+	public function assetManager();
48
+
49
+
50
+	/**
51
+	 * Registers the Editor Block with WP core;
52
+	 * Returns the registered block type on success, or false on failure.
53
+	 *
54
+	 * @return WP_Block_Type|false
55
+	 */
56
+	public function registerBlock();
57
+
58
+
59
+	/**
60
+	 * Un-registers the Editor Block with WP core;
61
+	 * Returns the registered block type on success, or false on failure.
62
+	 *
63
+	 * @return WP_Block_Type|false
64
+	 */
65
+	public function unRegisterBlock();
66
+
67
+
68
+	/**
69
+	 * returns true if the block type applies for the supplied post type
70
+	 * and should be added to that post type's editor
71
+	 *
72
+	 * @param string $post_type
73
+	 * @return boolean
74
+	 */
75
+	public function appliesToPostType($post_type);
76
+
77
+
78
+	/**
79
+	 * @return array
80
+	 */
81
+	public function getEditorContainer();
82
+
83
+
84
+	/**
85
+	 * returns the rendered HTML for the block
86
+	 *
87
+	 * @param array $attributes
88
+	 * @return string
89
+	 */
90
+	public function renderBlock(array $attributes = array());
91 91
 }
Please login to merge, or discard this patch.
core/services/assets/BlockAssetManager.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function setEditorScriptHandle($editor_script_handle)
59 59
     {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
60
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
61
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
62 62
         }
63 63
         $this->editor_script_handle = $editor_script_handle;
64 64
     }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function setEditorStyleHandle($editor_style_handle)
80 80
     {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
81
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
82
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
83 83
         }
84 84
         $this->editor_style_handle = $editor_style_handle;
85 85
     }
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function setScriptHandle($script_handle)
101 101
     {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
102
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
103
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
104 104
         }
105 105
         $this->script_handle = $script_handle;
106 106
     }
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function setStyleHandle($style_handle)
122 122
     {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
123
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
124
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
125 125
         }
126 126
         $this->style_handle = $style_handle;
127 127
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function addEditorScript($handle, array $dependencies = array())
154 154
     {
155
-        if($this->assets->has($handle)){
155
+        if ($this->assets->has($handle)) {
156 156
             return $this->assets->get($handle);
157 157
         }
158 158
         return parent::addJavascript(
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
     {
252 252
         $dependencies += array(
253 253
                 CoreAssetManager::JS_HANDLE_EE_JS_CORE,
254
-                'wp-blocks',    // Provides useful functions and components for extending the editor
255
-                'wp-i18n',      // Provides localization functions
256
-                'wp-element',   // Provides React.Component
254
+                'wp-blocks', // Provides useful functions and components for extending the editor
255
+                'wp-i18n', // Provides localization functions
256
+                'wp-element', // Provides React.Component
257 257
                 'wp-components' // Provides many prebuilt components and controls
258 258
             );
259 259
         return $dependencies;
Please login to merge, or discard this patch.
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -22,310 +22,310 @@
 block discarded – undo
22 22
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var string $editor_script_handle
27
-     */
28
-    private $editor_script_handle;
29
-
30
-    /**
31
-     * @var string $editor_style_handle
32
-     */
33
-    private $editor_style_handle;
34
-
35
-    /**
36
-     * @var string $script_handle
37
-     */
38
-    private $script_handle;
39
-
40
-    /**
41
-     * @var string $style_handle
42
-     */
43
-    private $style_handle;
44
-
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    public function getEditorScriptHandle()
50
-    {
51
-        return $this->editor_script_handle;
52
-    }
53
-
54
-
55
-    /**
56
-     * @param string $editor_script_handle
57
-     */
58
-    public function setEditorScriptHandle($editor_script_handle)
59
-    {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
-        }
63
-        $this->editor_script_handle = $editor_script_handle;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getEditorStyleHandle()
71
-    {
72
-        return $this->editor_style_handle;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param string $editor_style_handle
78
-     */
79
-    public function setEditorStyleHandle($editor_style_handle)
80
-    {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
-        }
84
-        $this->editor_style_handle = $editor_style_handle;
85
-    }
86
-
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function getScriptHandle()
92
-    {
93
-        return $this->script_handle;
94
-    }
95
-
96
-
97
-    /**
98
-     * @param string $script_handle
99
-     */
100
-    public function setScriptHandle($script_handle)
101
-    {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
-        }
105
-        $this->script_handle = $script_handle;
106
-    }
107
-
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getStyleHandle()
113
-    {
114
-        return $this->style_handle;
115
-    }
116
-
117
-
118
-    /**
119
-     * @param string $style_handle
120
-     */
121
-    public function setStyleHandle($style_handle)
122
-    {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
-        }
126
-        $this->style_handle = $style_handle;
127
-    }
128
-
129
-    /**
130
-     * @since $VID:$
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidEntityException
133
-     * @throws DuplicateCollectionIdentifierException
134
-     */
135
-    public function addAssets()
136
-    {
137
-        $this->addEditorScript($this->getEditorScriptHandle());
138
-        $this->addEditorStyle($this->getEditorStyleHandle());
139
-        $this->setScriptHandle($this->getScriptHandle());
140
-        $this->setStyleHandle($this->getStyleHandle());
141
-    }
142
-
143
-
144
-    /**
145
-     * @param       $handle
146
-     * @param array $dependencies
147
-     * @since $VID:$
148
-     * @return JavascriptAsset
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @throws DuplicateCollectionIdentifierException
152
-     */
153
-    public function addEditorScript($handle, array $dependencies = array())
154
-    {
155
-        if($this->assets->has($handle)){
156
-            return $this->assets->get($handle);
157
-        }
158
-        return parent::addJavascript(
159
-            $handle,
160
-            $this->registry->getJsUrl(
161
-                $this->domain->assetNamespace(),
162
-                $handle
163
-            ),
164
-            $this->addDefaultBlockScriptDependencies($dependencies)
165
-        )
166
-        ->setRequiresTranslation();
167
-    }
168
-
169
-
170
-    /**
171
-     * @param        $handle
172
-     * @param array  $dependencies
173
-     * @since $VID:$
174
-     * @return StylesheetAsset
175
-     * @throws InvalidDataTypeException
176
-     * @throws InvalidEntityException
177
-     * @throws DuplicateCollectionIdentifierException
178
-     */
179
-    public function addEditorStyle($handle, array $dependencies = array())
180
-    {
181
-        if ($this->assets->has($handle)) {
182
-            return $this->assets->get($handle);
183
-        }
184
-        return parent::addStylesheet(
185
-            $handle,
186
-            $this->registry->getCssUrl(
187
-                $this->domain->assetNamespace(),
188
-                $handle
189
-            ),
190
-            $dependencies
191
-        );
192
-    }
193
-
194
-
195
-    /**
196
-     * @param       $handle
197
-     * @param array $dependencies
198
-     * @since $VID:$
199
-     * @return JavascriptAsset
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidEntityException
202
-     * @throws DuplicateCollectionIdentifierException
203
-     */
204
-    public function addScript($handle, array $dependencies = array())
205
-    {
206
-        if ($this->assets->has($handle)) {
207
-            return $this->assets->get($handle);
208
-        }
209
-        return parent::addJavascript(
210
-            $handle,
211
-            $this->registry->getJsUrl(
212
-                $this->domain->assetNamespace(),
213
-                $handle
214
-            ),
215
-            $this->addDefaultBlockScriptDependencies($dependencies)
216
-        )
217
-        ->setRequiresTranslation();
218
-    }
219
-
220
-
221
-    /**
222
-     * @param        $handle
223
-     * @param array  $dependencies
224
-     * @since $VID:$
225
-     * @return StylesheetAsset
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidEntityException
228
-     * @throws DuplicateCollectionIdentifierException
229
-     */
230
-    public function addStyle($handle, array $dependencies = array())
231
-    {
232
-        if ($this->assets->has($handle)) {
233
-            return $this->assets->get($handle);
234
-        }
235
-        return parent::addStylesheet(
236
-            $handle,
237
-            $this->registry->getCssUrl(
238
-                $this->domain->assetNamespace(),
239
-                $handle
240
-            ),
241
-            $dependencies
242
-        );
243
-    }
244
-
245
-
246
-    /**
247
-     * @param array $dependencies
248
-     * @return array
249
-     */
250
-    protected function addDefaultBlockScriptDependencies(array $dependencies)
251
-    {
252
-        $dependencies += array(
253
-                CoreAssetManager::JS_HANDLE_EE_JS_CORE,
254
-                'wp-blocks',    // Provides useful functions and components for extending the editor
255
-                'wp-i18n',      // Provides localization functions
256
-                'wp-element',   // Provides React.Component
257
-                'wp-components' // Provides many prebuilt components and controls
258
-            );
259
-        return $dependencies;
260
-    }
261
-
262
-
263
-    /**
264
-     * @param string $handle
265
-     * @since $VID:$
266
-     * @return mixed|null
267
-     */
268
-    public function getAsset($handle)
269
-    {
270
-        if ($this->assets->has($handle)) {
271
-            return $this->assets->get($handle);
272
-        }
273
-        return null;
274
-    }
275
-
276
-
277
-    /**
278
-     * @return JavascriptAsset|null
279
-     */
280
-    public function getEditorScript()
281
-    {
282
-        return $this->getAsset($this->editor_script_handle);
283
-    }
284
-
285
-
286
-    /**
287
-     * @return StylesheetAsset|null
288
-     */
289
-    public function getEditorStyle()
290
-    {
291
-        return $this->getAsset($this->editor_style_handle);
292
-    }
293
-
294
-
295
-    /**
296
-     * @return JavascriptAsset|null
297
-     */
298
-    public function getScript()
299
-    {
300
-        return $this->getAsset($this->script_handle);
301
-    }
302
-
303
-
304
-    /**
305
-     * @return StylesheetAsset|null
306
-     */
307
-    public function getStyle()
308
-    {
309
-        return $this->getAsset($this->style_handle);
310
-    }
311
-
312
-
313
-    /**
314
-     * @return  void
315
-     */
316
-    public function enqueueAssets()
317
-    {
318
-        $assets = array(
319
-            $this->getEditorScript(),
320
-            $this->getEditorStyle(),
321
-            $this->getScript(),
322
-            $this->getStyle(),
323
-        );
324
-        foreach ($assets as $asset) {
325
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
326
-                $asset->enqueueAsset();
327
-            }
328
-        }
329
-    }
25
+	/**
26
+	 * @var string $editor_script_handle
27
+	 */
28
+	private $editor_script_handle;
29
+
30
+	/**
31
+	 * @var string $editor_style_handle
32
+	 */
33
+	private $editor_style_handle;
34
+
35
+	/**
36
+	 * @var string $script_handle
37
+	 */
38
+	private $script_handle;
39
+
40
+	/**
41
+	 * @var string $style_handle
42
+	 */
43
+	private $style_handle;
44
+
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function getEditorScriptHandle()
50
+	{
51
+		return $this->editor_script_handle;
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param string $editor_script_handle
57
+	 */
58
+	public function setEditorScriptHandle($editor_script_handle)
59
+	{
60
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
+		}
63
+		$this->editor_script_handle = $editor_script_handle;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getEditorStyleHandle()
71
+	{
72
+		return $this->editor_style_handle;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param string $editor_style_handle
78
+	 */
79
+	public function setEditorStyleHandle($editor_style_handle)
80
+	{
81
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
+		}
84
+		$this->editor_style_handle = $editor_style_handle;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function getScriptHandle()
92
+	{
93
+		return $this->script_handle;
94
+	}
95
+
96
+
97
+	/**
98
+	 * @param string $script_handle
99
+	 */
100
+	public function setScriptHandle($script_handle)
101
+	{
102
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
+		}
105
+		$this->script_handle = $script_handle;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getStyleHandle()
113
+	{
114
+		return $this->style_handle;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param string $style_handle
120
+	 */
121
+	public function setStyleHandle($style_handle)
122
+	{
123
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
+		}
126
+		$this->style_handle = $style_handle;
127
+	}
128
+
129
+	/**
130
+	 * @since $VID:$
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidEntityException
133
+	 * @throws DuplicateCollectionIdentifierException
134
+	 */
135
+	public function addAssets()
136
+	{
137
+		$this->addEditorScript($this->getEditorScriptHandle());
138
+		$this->addEditorStyle($this->getEditorStyleHandle());
139
+		$this->setScriptHandle($this->getScriptHandle());
140
+		$this->setStyleHandle($this->getStyleHandle());
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param       $handle
146
+	 * @param array $dependencies
147
+	 * @since $VID:$
148
+	 * @return JavascriptAsset
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @throws DuplicateCollectionIdentifierException
152
+	 */
153
+	public function addEditorScript($handle, array $dependencies = array())
154
+	{
155
+		if($this->assets->has($handle)){
156
+			return $this->assets->get($handle);
157
+		}
158
+		return parent::addJavascript(
159
+			$handle,
160
+			$this->registry->getJsUrl(
161
+				$this->domain->assetNamespace(),
162
+				$handle
163
+			),
164
+			$this->addDefaultBlockScriptDependencies($dependencies)
165
+		)
166
+		->setRequiresTranslation();
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param        $handle
172
+	 * @param array  $dependencies
173
+	 * @since $VID:$
174
+	 * @return StylesheetAsset
175
+	 * @throws InvalidDataTypeException
176
+	 * @throws InvalidEntityException
177
+	 * @throws DuplicateCollectionIdentifierException
178
+	 */
179
+	public function addEditorStyle($handle, array $dependencies = array())
180
+	{
181
+		if ($this->assets->has($handle)) {
182
+			return $this->assets->get($handle);
183
+		}
184
+		return parent::addStylesheet(
185
+			$handle,
186
+			$this->registry->getCssUrl(
187
+				$this->domain->assetNamespace(),
188
+				$handle
189
+			),
190
+			$dependencies
191
+		);
192
+	}
193
+
194
+
195
+	/**
196
+	 * @param       $handle
197
+	 * @param array $dependencies
198
+	 * @since $VID:$
199
+	 * @return JavascriptAsset
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidEntityException
202
+	 * @throws DuplicateCollectionIdentifierException
203
+	 */
204
+	public function addScript($handle, array $dependencies = array())
205
+	{
206
+		if ($this->assets->has($handle)) {
207
+			return $this->assets->get($handle);
208
+		}
209
+		return parent::addJavascript(
210
+			$handle,
211
+			$this->registry->getJsUrl(
212
+				$this->domain->assetNamespace(),
213
+				$handle
214
+			),
215
+			$this->addDefaultBlockScriptDependencies($dependencies)
216
+		)
217
+		->setRequiresTranslation();
218
+	}
219
+
220
+
221
+	/**
222
+	 * @param        $handle
223
+	 * @param array  $dependencies
224
+	 * @since $VID:$
225
+	 * @return StylesheetAsset
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidEntityException
228
+	 * @throws DuplicateCollectionIdentifierException
229
+	 */
230
+	public function addStyle($handle, array $dependencies = array())
231
+	{
232
+		if ($this->assets->has($handle)) {
233
+			return $this->assets->get($handle);
234
+		}
235
+		return parent::addStylesheet(
236
+			$handle,
237
+			$this->registry->getCssUrl(
238
+				$this->domain->assetNamespace(),
239
+				$handle
240
+			),
241
+			$dependencies
242
+		);
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param array $dependencies
248
+	 * @return array
249
+	 */
250
+	protected function addDefaultBlockScriptDependencies(array $dependencies)
251
+	{
252
+		$dependencies += array(
253
+				CoreAssetManager::JS_HANDLE_EE_JS_CORE,
254
+				'wp-blocks',    // Provides useful functions and components for extending the editor
255
+				'wp-i18n',      // Provides localization functions
256
+				'wp-element',   // Provides React.Component
257
+				'wp-components' // Provides many prebuilt components and controls
258
+			);
259
+		return $dependencies;
260
+	}
261
+
262
+
263
+	/**
264
+	 * @param string $handle
265
+	 * @since $VID:$
266
+	 * @return mixed|null
267
+	 */
268
+	public function getAsset($handle)
269
+	{
270
+		if ($this->assets->has($handle)) {
271
+			return $this->assets->get($handle);
272
+		}
273
+		return null;
274
+	}
275
+
276
+
277
+	/**
278
+	 * @return JavascriptAsset|null
279
+	 */
280
+	public function getEditorScript()
281
+	{
282
+		return $this->getAsset($this->editor_script_handle);
283
+	}
284
+
285
+
286
+	/**
287
+	 * @return StylesheetAsset|null
288
+	 */
289
+	public function getEditorStyle()
290
+	{
291
+		return $this->getAsset($this->editor_style_handle);
292
+	}
293
+
294
+
295
+	/**
296
+	 * @return JavascriptAsset|null
297
+	 */
298
+	public function getScript()
299
+	{
300
+		return $this->getAsset($this->script_handle);
301
+	}
302
+
303
+
304
+	/**
305
+	 * @return StylesheetAsset|null
306
+	 */
307
+	public function getStyle()
308
+	{
309
+		return $this->getAsset($this->style_handle);
310
+	}
311
+
312
+
313
+	/**
314
+	 * @return  void
315
+	 */
316
+	public function enqueueAssets()
317
+	{
318
+		$assets = array(
319
+			$this->getEditorScript(),
320
+			$this->getEditorStyle(),
321
+			$this->getScript(),
322
+			$this->getStyle(),
323
+		);
324
+		foreach ($assets as $asset) {
325
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
326
+				$asset->enqueueAsset();
327
+			}
328
+		}
329
+	}
330 330
 
331 331
 }
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Indentation   +1660 added lines, -1660 removed lines patch added patch discarded remove patch
@@ -23,1664 +23,1664 @@
 block discarded – undo
23 23
 class EE_Registry implements ResettableInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Registry $_instance
28
-     */
29
-    private static $_instance;
30
-
31
-    /**
32
-     * @var EE_Dependency_Map $_dependency_map
33
-     */
34
-    protected $_dependency_map;
35
-
36
-    /**
37
-     * @var Mirror
38
-     */
39
-    private $mirror;
40
-
41
-    /**
42
-     * @var ClassInterfaceCache $class_cache
43
-     */
44
-    private $class_cache;
45
-
46
-    /**
47
-     * @var array $_class_abbreviations
48
-     */
49
-    protected $_class_abbreviations = array();
50
-
51
-    /**
52
-     * @var CommandBusInterface $BUS
53
-     */
54
-    public $BUS;
55
-
56
-    /**
57
-     * @var EE_Cart $CART
58
-     */
59
-    public $CART;
60
-
61
-    /**
62
-     * @var EE_Config $CFG
63
-     */
64
-    public $CFG;
65
-
66
-    /**
67
-     * @var EE_Network_Config $NET_CFG
68
-     */
69
-    public $NET_CFG;
70
-
71
-    /**
72
-     * StdClass object for storing library classes in
73
-     *
74
-     * @var RegistryContainer $LIB
75
-     */
76
-    public $LIB;
77
-
78
-    /**
79
-     * @var EE_Request_Handler $REQ
80
-     */
81
-    public $REQ;
82
-
83
-    /**
84
-     * @var EE_Session $SSN
85
-     */
86
-    public $SSN;
87
-
88
-    /**
89
-     * @since 4.5.0
90
-     * @var EE_Capabilities $CAP
91
-     */
92
-    public $CAP;
93
-
94
-    /**
95
-     * @since 4.9.0
96
-     * @var EE_Message_Resource_Manager $MRM
97
-     */
98
-    public $MRM;
99
-
100
-    /**
101
-     * @var Registry $AssetsRegistry
102
-     */
103
-    public $AssetsRegistry;
104
-
105
-    /**
106
-     * StdClass object for holding addons which have registered themselves to work with EE core
107
-     *
108
-     * @var EE_Addon[] $addons
109
-     */
110
-    public $addons;
111
-
112
-    /**
113
-     * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
114
-     *
115
-     * @var EEM_Base[] $models
116
-     */
117
-    public $models = array();
118
-
119
-    /**
120
-     * @var EED_Module[] $modules
121
-     */
122
-    public $modules;
123
-
124
-    /**
125
-     * @var EES_Shortcode[] $shortcodes
126
-     */
127
-    public $shortcodes;
128
-
129
-    /**
130
-     * @var WP_Widget[] $widgets
131
-     */
132
-    public $widgets;
133
-
134
-    /**
135
-     * this is an array of all implemented model names (i.e. not the parent abstract models, or models
136
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
137
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
138
-     * classnames (eg "EEM_Event")
139
-     *
140
-     * @var array $non_abstract_db_models
141
-     */
142
-    public $non_abstract_db_models = array();
143
-
144
-    /**
145
-     * internationalization for JS strings
146
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
147
-     *    in js file:  var translatedString = eei18n.string_key;
148
-     *
149
-     * @var array $i18n_js_strings
150
-     */
151
-    public static $i18n_js_strings = array();
152
-
153
-    /**
154
-     * $main_file - path to espresso.php
155
-     *
156
-     * @var array $main_file
157
-     */
158
-    public $main_file;
159
-
160
-    /**
161
-     * array of ReflectionClass objects where the key is the class name
162
-     *
163
-     * @deprecated 4.9.62.p
164
-     * @var ReflectionClass[] $_reflectors
165
-     */
166
-    public $_reflectors;
167
-
168
-    /**
169
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
170
-     *
171
-     * @var boolean $_cache_on
172
-     */
173
-    protected $_cache_on = true;
174
-
175
-    /**
176
-     * @var ObjectIdentifier
177
-     */
178
-    private $object_identifier;
179
-
180
-
181
-    /**
182
-     * @singleton method used to instantiate class object
183
-     * @param EE_Dependency_Map|null   $dependency_map
184
-     * @param Mirror|null              $mirror
185
-     * @param ClassInterfaceCache|null $class_cache
186
-     * @param ObjectIdentifier|null    $object_identifier
187
-     * @return EE_Registry instance
188
-     */
189
-    public static function instance(
190
-        EE_Dependency_Map $dependency_map = null,
191
-        Mirror $mirror = null,
192
-        ClassInterfaceCache $class_cache = null,
193
-        ObjectIdentifier $object_identifier = null
194
-    ) {
195
-        // check if class object is instantiated
196
-        if (! self::$_instance instanceof EE_Registry
197
-            && $dependency_map instanceof EE_Dependency_Map
198
-            && $mirror instanceof Mirror
199
-            && $class_cache instanceof ClassInterfaceCache
200
-            && $object_identifier instanceof ObjectIdentifier
201
-        ) {
202
-            self::$_instance = new self(
203
-                $dependency_map,
204
-                $mirror,
205
-                $class_cache,
206
-                $object_identifier
207
-            );
208
-        }
209
-        return self::$_instance;
210
-    }
211
-
212
-
213
-    /**
214
-     * protected constructor to prevent direct creation
215
-     *
216
-     * @Constructor
217
-     * @param  EE_Dependency_Map  $dependency_map
218
-     * @param Mirror              $mirror
219
-     * @param ClassInterfaceCache $class_cache
220
-     * @param ObjectIdentifier    $object_identifier
221
-     */
222
-    protected function __construct(
223
-        EE_Dependency_Map $dependency_map,
224
-        Mirror $mirror,
225
-        ClassInterfaceCache $class_cache,
226
-        ObjectIdentifier $object_identifier
227
-    ) {
228
-        $this->_dependency_map = $dependency_map;
229
-        $this->mirror = $mirror;
230
-        $this->class_cache = $class_cache;
231
-        $this->object_identifier = $object_identifier;
232
-        // $registry_container = new RegistryContainer();
233
-        $this->LIB = new RegistryContainer();
234
-        $this->addons = new RegistryContainer();
235
-        $this->modules = new RegistryContainer();
236
-        $this->shortcodes = new RegistryContainer();
237
-        $this->widgets = new RegistryContainer();
238
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
239
-    }
240
-
241
-
242
-    /**
243
-     * initialize
244
-     *
245
-     * @throws OutOfBoundsException
246
-     * @throws InvalidArgumentException
247
-     * @throws InvalidInterfaceException
248
-     * @throws InvalidDataTypeException
249
-     * @throws EE_Error
250
-     * @throws ReflectionException
251
-     */
252
-    public function initialize()
253
-    {
254
-        $this->_class_abbreviations = apply_filters(
255
-            'FHEE__EE_Registry____construct___class_abbreviations',
256
-            array(
257
-                'EE_Config'                                       => 'CFG',
258
-                'EE_Session'                                      => 'SSN',
259
-                'EE_Capabilities'                                 => 'CAP',
260
-                'EE_Cart'                                         => 'CART',
261
-                'EE_Network_Config'                               => 'NET_CFG',
262
-                'EE_Request_Handler'                              => 'REQ',
263
-                'EE_Message_Resource_Manager'                     => 'MRM',
264
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
265
-                'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
266
-            )
267
-        );
268
-        $this->load_core('Base', array(), true);
269
-        // add our request and response objects to the cache
270
-        $request_loader = $this->_dependency_map->class_loader(
271
-            'EventEspresso\core\services\request\Request'
272
-        );
273
-        $this->_set_cached_class(
274
-            $request_loader(),
275
-            'EventEspresso\core\services\request\Request'
276
-        );
277
-        $response_loader = $this->_dependency_map->class_loader(
278
-            'EventEspresso\core\services\request\Response'
279
-        );
280
-        $this->_set_cached_class(
281
-            $response_loader(),
282
-            'EventEspresso\core\services\request\Response'
283
-        );
284
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
285
-    }
286
-
287
-
288
-    /**
289
-     * @return void
290
-     */
291
-    public function init()
292
-    {
293
-        // Get current page protocol
294
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
295
-        // Output admin-ajax.php URL with same protocol as current page
296
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
297
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
298
-    }
299
-
300
-
301
-    /**
302
-     * localize_i18n_js_strings
303
-     *
304
-     * @return string
305
-     */
306
-    public static function localize_i18n_js_strings()
307
-    {
308
-        $i18n_js_strings = (array) self::$i18n_js_strings;
309
-        foreach ($i18n_js_strings as $key => $value) {
310
-            if (is_scalar($value)) {
311
-                $i18n_js_strings[ $key ] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
312
-            }
313
-        }
314
-        return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
315
-    }
316
-
317
-
318
-    /**
319
-     * @param mixed string | EED_Module $module
320
-     * @throws OutOfBoundsException
321
-     * @throws InvalidArgumentException
322
-     * @throws InvalidInterfaceException
323
-     * @throws InvalidDataTypeException
324
-     * @throws EE_Error
325
-     * @throws ReflectionException
326
-     */
327
-    public function add_module($module)
328
-    {
329
-        if ($module instanceof EED_Module) {
330
-            $module_class = get_class($module);
331
-            $this->modules->{$module_class} = $module;
332
-        } else {
333
-            if (! class_exists('EE_Module_Request_Router', false)) {
334
-                $this->load_core('Module_Request_Router');
335
-            }
336
-            EE_Module_Request_Router::module_factory($module);
337
-        }
338
-    }
339
-
340
-
341
-    /**
342
-     * @param string $module_name
343
-     * @return mixed EED_Module | NULL
344
-     */
345
-    public function get_module($module_name = '')
346
-    {
347
-        return isset($this->modules->{$module_name})
348
-            ? $this->modules->{$module_name}
349
-            : null;
350
-    }
351
-
352
-
353
-    /**
354
-     * loads core classes - must be singletons
355
-     *
356
-     * @param string $class_name - simple class name ie: session
357
-     * @param mixed  $arguments
358
-     * @param bool   $load_only
359
-     * @return mixed
360
-     * @throws InvalidInterfaceException
361
-     * @throws InvalidDataTypeException
362
-     * @throws EE_Error
363
-     * @throws ReflectionException
364
-     * @throws InvalidArgumentException
365
-     */
366
-    public function load_core($class_name, $arguments = array(), $load_only = false)
367
-    {
368
-        $core_paths = apply_filters(
369
-            'FHEE__EE_Registry__load_core__core_paths',
370
-            array(
371
-                EE_CORE,
372
-                EE_ADMIN,
373
-                EE_CPTS,
374
-                EE_CORE . 'data_migration_scripts' . DS,
375
-                EE_CORE . 'capabilities' . DS,
376
-                EE_CORE . 'request_stack' . DS,
377
-                EE_CORE . 'middleware' . DS,
378
-            )
379
-        );
380
-        // retrieve instantiated class
381
-        return $this->_load(
382
-            $core_paths,
383
-            'EE_',
384
-            $class_name,
385
-            'core',
386
-            $arguments,
387
-            false,
388
-            true,
389
-            $load_only
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * loads service classes
396
-     *
397
-     * @param string $class_name - simple class name ie: session
398
-     * @param mixed  $arguments
399
-     * @param bool   $load_only
400
-     * @return mixed
401
-     * @throws InvalidInterfaceException
402
-     * @throws InvalidDataTypeException
403
-     * @throws EE_Error
404
-     * @throws ReflectionException
405
-     * @throws InvalidArgumentException
406
-     */
407
-    public function load_service($class_name, $arguments = array(), $load_only = false)
408
-    {
409
-        $service_paths = apply_filters(
410
-            'FHEE__EE_Registry__load_service__service_paths',
411
-            array(
412
-                EE_CORE . 'services' . DS,
413
-            )
414
-        );
415
-        // retrieve instantiated class
416
-        return $this->_load(
417
-            $service_paths,
418
-            'EE_',
419
-            $class_name,
420
-            'class',
421
-            $arguments,
422
-            false,
423
-            true,
424
-            $load_only
425
-        );
426
-    }
427
-
428
-
429
-    /**
430
-     * loads data_migration_scripts
431
-     *
432
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
433
-     * @param mixed  $arguments
434
-     * @return EE_Data_Migration_Script_Base|mixed
435
-     * @throws InvalidInterfaceException
436
-     * @throws InvalidDataTypeException
437
-     * @throws EE_Error
438
-     * @throws ReflectionException
439
-     * @throws InvalidArgumentException
440
-     */
441
-    public function load_dms($class_name, $arguments = array())
442
-    {
443
-        // retrieve instantiated class
444
-        return $this->_load(
445
-            EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
446
-            'EE_DMS_',
447
-            $class_name,
448
-            'dms',
449
-            $arguments,
450
-            false,
451
-            false
452
-        );
453
-    }
454
-
455
-
456
-    /**
457
-     * loads object creating classes - must be singletons
458
-     *
459
-     * @param string $class_name - simple class name ie: attendee
460
-     * @param mixed  $arguments  - an array of arguments to pass to the class
461
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
462
-     *                           instantiate
463
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
464
-     *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
465
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
466
-     *                           (default)
467
-     * @return EE_Base_Class | bool
468
-     * @throws InvalidInterfaceException
469
-     * @throws InvalidDataTypeException
470
-     * @throws EE_Error
471
-     * @throws ReflectionException
472
-     * @throws InvalidArgumentException
473
-     */
474
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
475
-    {
476
-        $paths = apply_filters(
477
-            'FHEE__EE_Registry__load_class__paths',
478
-            array(
479
-                EE_CORE,
480
-                EE_CLASSES,
481
-                EE_BUSINESS,
482
-            )
483
-        );
484
-        // retrieve instantiated class
485
-        return $this->_load(
486
-            $paths,
487
-            'EE_',
488
-            $class_name,
489
-            'class',
490
-            $arguments,
491
-            $from_db,
492
-            $cache,
493
-            $load_only
494
-        );
495
-    }
496
-
497
-
498
-    /**
499
-     * loads helper classes - must be singletons
500
-     *
501
-     * @param string $class_name - simple class name ie: price
502
-     * @param mixed  $arguments
503
-     * @param bool   $load_only
504
-     * @return EEH_Base | bool
505
-     * @throws InvalidInterfaceException
506
-     * @throws InvalidDataTypeException
507
-     * @throws EE_Error
508
-     * @throws ReflectionException
509
-     * @throws InvalidArgumentException
510
-     */
511
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
512
-    {
513
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
514
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
515
-        // retrieve instantiated class
516
-        return $this->_load(
517
-            $helper_paths,
518
-            'EEH_',
519
-            $class_name,
520
-            'helper',
521
-            $arguments,
522
-            false,
523
-            true,
524
-            $load_only
525
-        );
526
-    }
527
-
528
-
529
-    /**
530
-     * loads core classes - must be singletons
531
-     *
532
-     * @param string $class_name - simple class name ie: session
533
-     * @param mixed  $arguments
534
-     * @param bool   $load_only
535
-     * @param bool   $cache      whether to cache the object or not.
536
-     * @return mixed
537
-     * @throws InvalidInterfaceException
538
-     * @throws InvalidDataTypeException
539
-     * @throws EE_Error
540
-     * @throws ReflectionException
541
-     * @throws InvalidArgumentException
542
-     */
543
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
544
-    {
545
-        $paths = array(
546
-            EE_LIBRARIES,
547
-            EE_LIBRARIES . 'messages' . DS,
548
-            EE_LIBRARIES . 'shortcodes' . DS,
549
-            EE_LIBRARIES . 'qtips' . DS,
550
-            EE_LIBRARIES . 'payment_methods' . DS,
551
-        );
552
-        // retrieve instantiated class
553
-        return $this->_load(
554
-            $paths,
555
-            'EE_',
556
-            $class_name,
557
-            'lib',
558
-            $arguments,
559
-            false,
560
-            $cache,
561
-            $load_only
562
-        );
563
-    }
564
-
565
-
566
-    /**
567
-     * loads model classes - must be singletons
568
-     *
569
-     * @param string $class_name - simple class name ie: price
570
-     * @param mixed  $arguments
571
-     * @param bool   $load_only
572
-     * @return EEM_Base | bool
573
-     * @throws InvalidInterfaceException
574
-     * @throws InvalidDataTypeException
575
-     * @throws EE_Error
576
-     * @throws ReflectionException
577
-     * @throws InvalidArgumentException
578
-     */
579
-    public function load_model($class_name, $arguments = array(), $load_only = false)
580
-    {
581
-        $paths = apply_filters(
582
-            'FHEE__EE_Registry__load_model__paths',
583
-            array(
584
-                EE_MODELS,
585
-                EE_CORE,
586
-            )
587
-        );
588
-        // retrieve instantiated class
589
-        return $this->_load(
590
-            $paths,
591
-            'EEM_',
592
-            $class_name,
593
-            'model',
594
-            $arguments,
595
-            false,
596
-            true,
597
-            $load_only
598
-        );
599
-    }
600
-
601
-
602
-    /**
603
-     * loads model classes - must be singletons
604
-     *
605
-     * @param string $class_name - simple class name ie: price
606
-     * @param mixed  $arguments
607
-     * @param bool   $load_only
608
-     * @return mixed | bool
609
-     * @throws InvalidInterfaceException
610
-     * @throws InvalidDataTypeException
611
-     * @throws EE_Error
612
-     * @throws ReflectionException
613
-     * @throws InvalidArgumentException
614
-     */
615
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
616
-    {
617
-        $paths = array(
618
-            EE_MODELS . 'fields' . DS,
619
-            EE_MODELS . 'helpers' . DS,
620
-            EE_MODELS . 'relations' . DS,
621
-            EE_MODELS . 'strategies' . DS,
622
-        );
623
-        // retrieve instantiated class
624
-        return $this->_load(
625
-            $paths,
626
-            'EE_',
627
-            $class_name,
628
-            '',
629
-            $arguments,
630
-            false,
631
-            true,
632
-            $load_only
633
-        );
634
-    }
635
-
636
-
637
-    /**
638
-     * Determines if $model_name is the name of an actual EE model.
639
-     *
640
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
641
-     * @return boolean
642
-     */
643
-    public function is_model_name($model_name)
644
-    {
645
-        return isset($this->models[ $model_name ]);
646
-    }
647
-
648
-
649
-    /**
650
-     * generic class loader
651
-     *
652
-     * @param string $path_to_file - directory path to file location, not including filename
653
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
654
-     * @param string $type         - file type - core? class? helper? model?
655
-     * @param mixed  $arguments
656
-     * @param bool   $load_only
657
-     * @return mixed
658
-     * @throws InvalidInterfaceException
659
-     * @throws InvalidDataTypeException
660
-     * @throws EE_Error
661
-     * @throws ReflectionException
662
-     * @throws InvalidArgumentException
663
-     */
664
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
665
-    {
666
-        // retrieve instantiated class
667
-        return $this->_load(
668
-            $path_to_file,
669
-            '',
670
-            $file_name,
671
-            $type,
672
-            $arguments,
673
-            false,
674
-            true,
675
-            $load_only
676
-        );
677
-    }
678
-
679
-
680
-    /**
681
-     * @param string $path_to_file - directory path to file location, not including filename
682
-     * @param string $class_name   - full class name  ie:  My_Class
683
-     * @param string $type         - file type - core? class? helper? model?
684
-     * @param mixed  $arguments
685
-     * @param bool   $load_only
686
-     * @return bool|EE_Addon|object
687
-     * @throws InvalidInterfaceException
688
-     * @throws InvalidDataTypeException
689
-     * @throws EE_Error
690
-     * @throws ReflectionException
691
-     * @throws InvalidArgumentException
692
-     */
693
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
694
-    {
695
-        // retrieve instantiated class
696
-        return $this->_load(
697
-            $path_to_file,
698
-            'addon',
699
-            $class_name,
700
-            $type,
701
-            $arguments,
702
-            false,
703
-            true,
704
-            $load_only
705
-        );
706
-    }
707
-
708
-
709
-    /**
710
-     * instantiates, caches, and automatically resolves dependencies
711
-     * for classes that use a Fully Qualified Class Name.
712
-     * if the class is not capable of being loaded using PSR-4 autoloading,
713
-     * then you need to use one of the existing load_*() methods
714
-     * which can resolve the classname and filepath from the passed arguments
715
-     *
716
-     * @param bool|string $class_name   Fully Qualified Class Name
717
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
718
-     * @param bool        $cache        whether to cache the instantiated object for reuse
719
-     * @param bool        $from_db      some classes are instantiated from the db
720
-     *                                  and thus call a different method to instantiate
721
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
722
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
723
-     * @return bool|null|mixed          null = failure to load or instantiate class object.
724
-     *                                  object = class loaded and instantiated successfully.
725
-     *                                  bool = fail or success when $load_only is true
726
-     * @throws InvalidInterfaceException
727
-     * @throws InvalidDataTypeException
728
-     * @throws EE_Error
729
-     * @throws ReflectionException
730
-     * @throws InvalidArgumentException
731
-     */
732
-    public function create(
733
-        $class_name = false,
734
-        $arguments = array(),
735
-        $cache = false,
736
-        $from_db = false,
737
-        $load_only = false,
738
-        $addon = false
739
-    ) {
740
-        $class_name = ltrim($class_name, '\\');
741
-        $class_name = $this->class_cache->getFqnForAlias($class_name);
742
-        $class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
743
-        // if a non-FQCN was passed, then
744
-        // verifyClassExists() might return an object
745
-        // or it could return null if the class just could not be found anywhere
746
-        if ($class_exists instanceof $class_name || $class_exists === null) {
747
-            // either way, return the results
748
-            return $class_exists;
749
-        }
750
-        $class_name = $class_exists;
751
-        // if we're only loading the class and it already exists, then let's just return true immediately
752
-        if ($load_only) {
753
-            return true;
754
-        }
755
-        $addon = $addon ? 'addon' : '';
756
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
757
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
758
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
759
-        if ($this->_cache_on && $cache && ! $load_only) {
760
-            // return object if it's already cached
761
-            $cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
762
-            if ($cached_class !== null) {
763
-                return $cached_class;
764
-            }
765
-        }// obtain the loader method from the dependency map
766
-        $loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
767
-        if ($loader instanceof Closure) {
768
-            $class_obj = $loader($arguments);
769
-        } else {
770
-            if ($loader && method_exists($this, $loader)) {
771
-                $class_obj = $this->{$loader}($class_name, $arguments);
772
-            } else {
773
-                $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
774
-            }
775
-        }
776
-        if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
777
-            // save it for later... kinda like gum  { : $
778
-            $this->_set_cached_class(
779
-                $class_obj,
780
-                $class_name,
781
-                $addon,
782
-                $from_db,
783
-                $arguments
784
-            );
785
-        }
786
-        $this->_cache_on = true;
787
-        return $class_obj;
788
-    }
789
-
790
-
791
-    /**
792
-     * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
793
-     *
794
-     * @param string|object $class_name
795
-     * @param array         $arguments
796
-     * @param int           $attempt
797
-     * @return mixed
798
-     */
799
-    private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1)
800
-    {
801
-        if (is_object($class_name) || class_exists($class_name)) {
802
-            return $class_name;
803
-        }
804
-        switch ($attempt) {
805
-            case 1:
806
-                // if it's a FQCN then maybe the class is registered with a preceding \
807
-                $class_name = strpos($class_name, '\\') !== false
808
-                    ? '\\' . ltrim($class_name, '\\')
809
-                    : $class_name;
810
-                break;
811
-            case 2:
812
-                //
813
-                $loader = $this->_dependency_map->class_loader($class_name);
814
-                if ($loader && method_exists($this, $loader)) {
815
-                    return $this->{$loader}($class_name, $arguments);
816
-                }
817
-                break;
818
-            case 3:
819
-            default:
820
-                return null;
821
-        }
822
-        $attempt++;
823
-        return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
824
-    }
825
-
826
-
827
-    /**
828
-     * instantiates, caches, and injects dependencies for classes
829
-     *
830
-     * @param array       $file_paths   an array of paths to folders to look in
831
-     * @param string      $class_prefix EE  or EEM or... ???
832
-     * @param bool|string $class_name   $class name
833
-     * @param string      $type         file type - core? class? helper? model?
834
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
835
-     * @param bool        $from_db      some classes are instantiated from the db
836
-     *                                  and thus call a different method to instantiate
837
-     * @param bool        $cache        whether to cache the instantiated object for reuse
838
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
839
-     * @return bool|null|object null = failure to load or instantiate class object.
840
-     *                                  object = class loaded and instantiated successfully.
841
-     *                                  bool = fail or success when $load_only is true
842
-     * @throws EE_Error
843
-     * @throws ReflectionException
844
-     * @throws InvalidInterfaceException
845
-     * @throws InvalidDataTypeException
846
-     * @throws InvalidArgumentException
847
-     */
848
-    protected function _load(
849
-        $file_paths = array(),
850
-        $class_prefix = 'EE_',
851
-        $class_name = false,
852
-        $type = 'class',
853
-        $arguments = array(),
854
-        $from_db = false,
855
-        $cache = true,
856
-        $load_only = false
857
-    ) {
858
-        $class_name = ltrim($class_name, '\\');
859
-        // strip php file extension
860
-        $class_name = str_replace('.php', '', trim($class_name));
861
-        // does the class have a prefix ?
862
-        if (! empty($class_prefix) && $class_prefix !== 'addon') {
863
-            // make sure $class_prefix is uppercase
864
-            $class_prefix = strtoupper(trim($class_prefix));
865
-            // add class prefix ONCE!!!
866
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
867
-        }
868
-        $class_name = $this->class_cache->getFqnForAlias($class_name);
869
-        $class_exists = class_exists($class_name, false);
870
-        // if we're only loading the class and it already exists, then let's just return true immediately
871
-        if ($load_only && $class_exists) {
872
-            return true;
873
-        }
874
-        $arguments = is_array($arguments) ? $arguments : array($arguments);
875
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
876
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
877
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
878
-        if ($this->_cache_on && $cache && ! $load_only) {
879
-            // return object if it's already cached
880
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
881
-            if ($cached_class !== null) {
882
-                return $cached_class;
883
-            }
884
-        }
885
-        // if the class doesn't already exist.. then we need to try and find the file and load it
886
-        if (! $class_exists) {
887
-            // get full path to file
888
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
889
-            // load the file
890
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
891
-            // if we are only loading a file but NOT instantiating an object
892
-            // then return boolean for whether class was loaded or not
893
-            if ($load_only) {
894
-                return $loaded;
895
-            }
896
-            // if an object was expected but loading failed, then return nothing
897
-            if (! $loaded) {
898
-                return null;
899
-            }
900
-        }
901
-        // instantiate the requested object
902
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
903
-        if ($this->_cache_on && $cache) {
904
-            // save it for later... kinda like gum  { : $
905
-            $this->_set_cached_class(
906
-                $class_obj,
907
-                $class_name,
908
-                $class_prefix,
909
-                $from_db,
910
-                $arguments
911
-            );
912
-        }
913
-        $this->_cache_on = true;
914
-        return $class_obj;
915
-    }
916
-
917
-
918
-    /**
919
-     * @param string $class_name
920
-     * @param string $default have to specify something, but not anything that will conflict
921
-     * @return mixed|string
922
-     */
923
-    protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
924
-    {
925
-        return isset($this->_class_abbreviations[ $class_name ])
926
-            ? $this->_class_abbreviations[ $class_name ]
927
-            : $default;
928
-    }
929
-
930
-
931
-    /**
932
-     * attempts to find a cached version of the requested class
933
-     * by looking in the following places:
934
-     *        $this->{$class_abbreviation}            ie:    $this->CART
935
-     *        $this->{$class_name}                        ie:    $this->Some_Class
936
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
937
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
938
-     *
939
-     * @param string $class_name
940
-     * @param string $class_prefix
941
-     * @param array  $arguments
942
-     * @return mixed
943
-     */
944
-    protected function _get_cached_class(
945
-        $class_name,
946
-        $class_prefix = '',
947
-        $arguments = array()
948
-    ) {
949
-        if ($class_name === 'EE_Registry') {
950
-            return $this;
951
-        }
952
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
953
-        // check if class has already been loaded, and return it if it has been
954
-        if (isset($this->{$class_abbreviation})) {
955
-            return $this->{$class_abbreviation};
956
-        }
957
-        $class_name = str_replace('\\', '_', $class_name);
958
-        if (isset($this->{$class_name})) {
959
-            return $this->{$class_name};
960
-        }
961
-        if ($class_prefix === 'addon' && isset($this->addons->{$class_name})) {
962
-            return $this->addons->{$class_name};
963
-        }
964
-        $object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
965
-        if (isset($this->LIB->{$object_identifier})) {
966
-            return $this->LIB->{$object_identifier};
967
-        }
968
-        foreach ($this->LIB as $key => $object) {
969
-            if (// request does not contain new arguments and therefore no args identifier
970
-                ! $this->object_identifier->hasArguments($object_identifier)
971
-                // but previously cached class with args was found
972
-                && $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
973
-            ) {
974
-                return $object;
975
-            }
976
-        }
977
-        return null;
978
-    }
979
-
980
-
981
-    /**
982
-     * removes a cached version of the requested class
983
-     *
984
-     * @param string  $class_name
985
-     * @param boolean $addon
986
-     * @param array   $arguments
987
-     * @return boolean
988
-     */
989
-    public function clear_cached_class(
990
-        $class_name,
991
-        $addon = false,
992
-        $arguments = array()
993
-    ) {
994
-        $class_abbreviation = $this->get_class_abbreviation($class_name);
995
-        // check if class has already been loaded, and return it if it has been
996
-        if (isset($this->{$class_abbreviation})) {
997
-            $this->{$class_abbreviation} = null;
998
-            return true;
999
-        }
1000
-        $class_name = str_replace('\\', '_', $class_name);
1001
-        if (isset($this->{$class_name})) {
1002
-            $this->{$class_name} = null;
1003
-            return true;
1004
-        }
1005
-        if ($addon && isset($this->addons->{$class_name})) {
1006
-            unset($this->addons->{$class_name});
1007
-            return true;
1008
-        }
1009
-        $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1010
-        if (isset($this->LIB->{$class_name})) {
1011
-            unset($this->LIB->{$class_name});
1012
-            return true;
1013
-        }
1014
-        return false;
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * _set_cached_class
1020
-     * attempts to cache the instantiated class locally
1021
-     * in one of the following places, in the following order:
1022
-     *        $this->{class_abbreviation}   ie:    $this->CART
1023
-     *        $this->{$class_name}          ie:    $this->Some_Class
1024
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1025
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1026
-     *
1027
-     * @param object $class_obj
1028
-     * @param string $class_name
1029
-     * @param string $class_prefix
1030
-     * @param bool   $from_db
1031
-     * @param array  $arguments
1032
-     * @return void
1033
-     */
1034
-    protected function _set_cached_class(
1035
-        $class_obj,
1036
-        $class_name,
1037
-        $class_prefix = '',
1038
-        $from_db = false,
1039
-        $arguments = array()
1040
-    ) {
1041
-        if ($class_name === 'EE_Registry' || empty($class_obj)) {
1042
-            return;
1043
-        }
1044
-        // return newly instantiated class
1045
-        $class_abbreviation = $this->get_class_abbreviation($class_name, '');
1046
-        if ($class_abbreviation) {
1047
-            $this->{$class_abbreviation} = $class_obj;
1048
-            return;
1049
-        }
1050
-        $class_name = str_replace('\\', '_', $class_name);
1051
-        if (property_exists($this, $class_name)) {
1052
-            $this->{$class_name} = $class_obj;
1053
-            return;
1054
-        }
1055
-        if ($class_prefix === 'addon') {
1056
-            $this->addons->{$class_name} = $class_obj;
1057
-            return;
1058
-        }
1059
-        if (! $from_db) {
1060
-            $class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1061
-            $this->LIB->{$class_name} = $class_obj;
1062
-        }
1063
-    }
1064
-
1065
-
1066
-    /**
1067
-     * attempts to find a full valid filepath for the requested class.
1068
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1069
-     * then returns that path if the target file has been found and is readable
1070
-     *
1071
-     * @param string $class_name
1072
-     * @param string $type
1073
-     * @param array  $file_paths
1074
-     * @return string | bool
1075
-     */
1076
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
1077
-    {
1078
-        // make sure $file_paths is an array
1079
-        $file_paths = is_array($file_paths)
1080
-            ? $file_paths
1081
-            : array($file_paths);
1082
-        // cycle thru paths
1083
-        foreach ($file_paths as $key => $file_path) {
1084
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
1085
-            $file_path = $file_path
1086
-                ? str_replace(array('/', '\\'), DS, $file_path)
1087
-                : EE_CLASSES;
1088
-            // prep file type
1089
-            $type = ! empty($type)
1090
-                ? trim($type, '.') . '.'
1091
-                : '';
1092
-            // build full file path
1093
-            $file_paths[ $key ] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
1094
-            // does the file exist and can be read ?
1095
-            if (is_readable($file_paths[ $key ])) {
1096
-                return $file_paths[ $key ];
1097
-            }
1098
-        }
1099
-        return false;
1100
-    }
1101
-
1102
-
1103
-    /**
1104
-     * basically just performs a require_once()
1105
-     * but with some error handling
1106
-     *
1107
-     * @param  string $path
1108
-     * @param  string $class_name
1109
-     * @param  string $type
1110
-     * @param  array  $file_paths
1111
-     * @return bool
1112
-     * @throws EE_Error
1113
-     * @throws ReflectionException
1114
-     */
1115
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
1116
-    {
1117
-        $this->resolve_legacy_class_parent($class_name);
1118
-        // don't give up! you gotta...
1119
-        try {
1120
-            // does the file exist and can it be read ?
1121
-            if (! $path) {
1122
-                // just in case the file has already been autoloaded,
1123
-                // but discrepancies in the naming schema are preventing it from
1124
-                // being loaded via one of the EE_Registry::load_*() methods,
1125
-                // then let's try one last hail mary before throwing an exception
1126
-                // and call class_exists() again, but with autoloading turned ON
1127
-                if (class_exists($class_name)) {
1128
-                    return true;
1129
-                }
1130
-                // so sorry, can't find the file
1131
-                throw new EE_Error(
1132
-                    sprintf(
1133
-                        esc_html__(
1134
-                            'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1135
-                            'event_espresso'
1136
-                        ),
1137
-                        trim($type, '.'),
1138
-                        $class_name,
1139
-                        '<br />' . implode(',<br />', $file_paths)
1140
-                    )
1141
-                );
1142
-            }
1143
-            // get the file
1144
-            require_once($path);
1145
-            // if the class isn't already declared somewhere
1146
-            if (class_exists($class_name, false) === false) {
1147
-                // so sorry, not a class
1148
-                throw new EE_Error(
1149
-                    sprintf(
1150
-                        esc_html__(
1151
-                            'The %s file %s does not appear to contain the %s Class.',
1152
-                            'event_espresso'
1153
-                        ),
1154
-                        $type,
1155
-                        $path,
1156
-                        $class_name
1157
-                    )
1158
-                );
1159
-            }
1160
-        } catch (EE_Error $e) {
1161
-            $e->get_error();
1162
-            return false;
1163
-        }
1164
-        return true;
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * Some of our legacy classes that extended a parent class would simply use a require() statement
1170
-     * before their class declaration in order to ensure that the parent class was loaded.
1171
-     * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1172
-     * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1173
-     *
1174
-     * @param string $class_name
1175
-     */
1176
-    protected function resolve_legacy_class_parent($class_name = '')
1177
-    {
1178
-        try {
1179
-            $legacy_parent_class_map = array(
1180
-                'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1181
-            );
1182
-            if (isset($legacy_parent_class_map[ $class_name ])) {
1183
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1184
-            }
1185
-        } catch (Exception $exception) {
1186
-        }
1187
-    }
1188
-
1189
-
1190
-    /**
1191
-     * _create_object
1192
-     * Attempts to instantiate the requested class via any of the
1193
-     * commonly used instantiation methods employed throughout EE.
1194
-     * The priority for instantiation is as follows:
1195
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1196
-     *        - model objects via their 'new_instance_from_db' method
1197
-     *        - model objects via their 'new_instance' method
1198
-     *        - "singleton" classes" via their 'instance' method
1199
-     *    - standard instantiable classes via their __constructor
1200
-     * Prior to instantiation, if the classname exists in the dependency_map,
1201
-     * then the constructor for the requested class will be examined to determine
1202
-     * if any dependencies exist, and if they can be injected.
1203
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1204
-     *
1205
-     * @param string $class_name
1206
-     * @param array  $arguments
1207
-     * @param string $type
1208
-     * @param bool   $from_db
1209
-     * @return null|object|bool
1210
-     * @throws InvalidArgumentException
1211
-     * @throws InvalidInterfaceException
1212
-     * @throws EE_Error
1213
-     * @throws ReflectionException
1214
-     * @throws InvalidDataTypeException
1215
-     */
1216
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1217
-    {
1218
-        // create reflection
1219
-        $reflector = $this->mirror->getReflectionClass($class_name);
1220
-        // make sure arguments are an array
1221
-        $arguments = is_array($arguments)
1222
-            ? $arguments
1223
-            : array($arguments);
1224
-        // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1225
-        // else wrap it in an additional array so that it doesn't get split into multiple parameters
1226
-        $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1227
-            ? $arguments
1228
-            : array($arguments);
1229
-        // attempt to inject dependencies ?
1230
-        if ($this->_dependency_map->has($class_name)) {
1231
-            $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1232
-        }
1233
-        // instantiate the class if possible
1234
-        if ($reflector->isAbstract()) {
1235
-            // nothing to instantiate, loading file was enough
1236
-            // does not throw an exception so $instantiation_mode is unused
1237
-            // $instantiation_mode = "1) no constructor abstract class";
1238
-            return true;
1239
-        }
1240
-        if (empty($arguments)
1241
-            && $this->mirror->getConstructorFromReflection($reflector) === null
1242
-            && $reflector->isInstantiable()
1243
-        ) {
1244
-            // no constructor = static methods only... nothing to instantiate, loading file was enough
1245
-            // $instantiation_mode = "2) no constructor but instantiable";
1246
-            return $reflector->newInstance();
1247
-        }
1248
-        if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1249
-            // $instantiation_mode = "3) new_instance_from_db()";
1250
-            return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1251
-        }
1252
-        if (method_exists($class_name, 'new_instance')) {
1253
-            // $instantiation_mode = "4) new_instance()";
1254
-            return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1255
-        }
1256
-        if (method_exists($class_name, 'instance')) {
1257
-            // $instantiation_mode = "5) instance()";
1258
-            return call_user_func_array(array($class_name, 'instance'), $arguments);
1259
-        }
1260
-        if ($reflector->isInstantiable()) {
1261
-            // $instantiation_mode = "6) constructor";
1262
-            return $reflector->newInstanceArgs($arguments);
1263
-        }
1264
-        // heh ? something's not right !
1265
-        throw new EE_Error(
1266
-            sprintf(
1267
-                __('The %s file %s could not be instantiated.', 'event_espresso'),
1268
-                $type,
1269
-                $class_name
1270
-            )
1271
-        );
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1277
-     * @param array $array
1278
-     * @return bool
1279
-     */
1280
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
1281
-    {
1282
-        return ! empty($array)
1283
-            ? array_keys($array) === range(0, count($array) - 1)
1284
-            : true;
1285
-    }
1286
-
1287
-
1288
-    /**
1289
-     * _resolve_dependencies
1290
-     * examines the constructor for the requested class to determine
1291
-     * if any dependencies exist, and if they can be injected.
1292
-     * If so, then those classes will be added to the array of arguments passed to the constructor
1293
-     * PLZ NOTE: this is achieved by type hinting the constructor params
1294
-     * For example:
1295
-     *        if attempting to load a class "Foo" with the following constructor:
1296
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
1297
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
1298
-     *        but only IF they are NOT already present in the incoming arguments array,
1299
-     *        and the correct classes can be loaded
1300
-     *
1301
-     * @param ReflectionClass $reflector
1302
-     * @param string          $class_name
1303
-     * @param array           $arguments
1304
-     * @return array
1305
-     * @throws InvalidArgumentException
1306
-     * @throws InvalidDataTypeException
1307
-     * @throws InvalidInterfaceException
1308
-     * @throws ReflectionException
1309
-     */
1310
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, array $arguments = array())
1311
-    {
1312
-        // let's examine the constructor
1313
-        $constructor = $this->mirror->getConstructorFromReflection($reflector);
1314
-        // whu? huh? nothing?
1315
-        if (! $constructor) {
1316
-            return $arguments;
1317
-        }
1318
-        // get constructor parameters
1319
-        $params = $this->mirror->getParametersFromReflection($reflector);
1320
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1321
-        $argument_keys = array_keys($arguments);
1322
-        // now loop thru all of the constructors expected parameters
1323
-        foreach ($params as $index => $param) {
1324
-            // is this a dependency for a specific class ?
1325
-            $param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1326
-            // BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1327
-            $param_class = $this->class_cache->isAlias($param_class, $class_name)
1328
-                ? $this->class_cache->getFqnForAlias($param_class, $class_name)
1329
-                : $param_class;
1330
-            if (// param is not even a class
1331
-                $param_class === null
1332
-                // and something already exists in the incoming arguments for this param
1333
-                && array_key_exists($index, $argument_keys)
1334
-                && array_key_exists($argument_keys[ $index ], $arguments)
1335
-            ) {
1336
-                // so let's skip this argument and move on to the next
1337
-                continue;
1338
-            }
1339
-            if (// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1340
-                $param_class !== null
1341
-                && isset($argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ])
1342
-                && $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1343
-            ) {
1344
-                // skip this argument and move on to the next
1345
-                continue;
1346
-            }
1347
-            if (// parameter is type hinted as a class, and should be injected
1348
-                $param_class !== null
1349
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1350
-            ) {
1351
-                $arguments = $this->_resolve_dependency(
1352
-                    $class_name,
1353
-                    $param_class,
1354
-                    $arguments,
1355
-                    $index
1356
-                );
1357
-            } else {
1358
-                $arguments[ $index ] = $this->mirror->getParameterDefaultValue(
1359
-                    $param,
1360
-                    $class_name,
1361
-                    $index
1362
-                );
1363
-            }
1364
-        }
1365
-        return $arguments;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * @param string $class_name
1371
-     * @param string $param_class
1372
-     * @param array  $arguments
1373
-     * @param mixed  $index
1374
-     * @return array
1375
-     * @throws InvalidArgumentException
1376
-     * @throws InvalidInterfaceException
1377
-     * @throws InvalidDataTypeException
1378
-     */
1379
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1380
-    {
1381
-        $dependency = null;
1382
-        // should dependency be loaded from cache ?
1383
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1384
-            $class_name,
1385
-            $param_class
1386
-        );
1387
-        $cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1388
-        // we might have a dependency...
1389
-        // let's MAYBE try and find it in our cache if that's what's been requested
1390
-        $cached_class = $cache_on
1391
-            ? $this->_get_cached_class($param_class)
1392
-            : null;
1393
-        // and grab it if it exists
1394
-        if ($cached_class instanceof $param_class) {
1395
-            $dependency = $cached_class;
1396
-        } elseif ($param_class !== $class_name) {
1397
-            // obtain the loader method from the dependency map
1398
-            $loader = $this->_dependency_map->class_loader($param_class);
1399
-            // is loader a custom closure ?
1400
-            if ($loader instanceof Closure) {
1401
-                $dependency = $loader($arguments);
1402
-            } else {
1403
-                // set the cache on property for the recursive loading call
1404
-                $this->_cache_on = $cache_on;
1405
-                // if not, then let's try and load it via the registry
1406
-                if ($loader && method_exists($this, $loader)) {
1407
-                    $dependency = $this->{$loader}($param_class);
1408
-                } else {
1409
-                    $dependency = LoaderFactory::getLoader()->load(
1410
-                        $param_class,
1411
-                        array(),
1412
-                        $cache_on
1413
-                    );
1414
-                }
1415
-            }
1416
-        }
1417
-        // did we successfully find the correct dependency ?
1418
-        if ($dependency instanceof $param_class) {
1419
-            // then let's inject it into the incoming array of arguments at the correct location
1420
-            $arguments[ $index ] = $dependency;
1421
-        }
1422
-        return $arguments;
1423
-    }
1424
-
1425
-
1426
-    /**
1427
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1428
-     *
1429
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1430
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1431
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1432
-     * @param array  $arguments
1433
-     * @return object
1434
-     */
1435
-    public static function factory($classname, $arguments = array())
1436
-    {
1437
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1438
-        if ($loader instanceof Closure) {
1439
-            return $loader($arguments);
1440
-        }
1441
-        if (method_exists(self::instance(), $loader)) {
1442
-            return self::instance()->{$loader}($classname, $arguments);
1443
-        }
1444
-        return null;
1445
-    }
1446
-
1447
-
1448
-    /**
1449
-     * Gets the addon by its class name
1450
-     *
1451
-     * @param string $class_name
1452
-     * @return EE_Addon
1453
-     */
1454
-    public function getAddon($class_name)
1455
-    {
1456
-        $class_name = str_replace('\\', '_', $class_name);
1457
-        return $this->addons->{$class_name};
1458
-    }
1459
-
1460
-
1461
-    /**
1462
-     * removes the addon from the internal cache
1463
-     *
1464
-     * @param string $class_name
1465
-     * @return void
1466
-     */
1467
-    public function removeAddon($class_name)
1468
-    {
1469
-        $class_name = str_replace('\\', '_', $class_name);
1470
-        unset($this->addons->{$class_name});
1471
-    }
1472
-
1473
-
1474
-    /**
1475
-     * Gets the addon by its name/slug (not classname. For that, just
1476
-     * use the get_addon() method above
1477
-     *
1478
-     * @param string $name
1479
-     * @return EE_Addon
1480
-     */
1481
-    public function get_addon_by_name($name)
1482
-    {
1483
-        foreach ($this->addons as $addon) {
1484
-            if ($addon->name() === $name) {
1485
-                return $addon;
1486
-            }
1487
-        }
1488
-        return null;
1489
-    }
1490
-
1491
-
1492
-    /**
1493
-     * Gets an array of all the registered addons, where the keys are their names.
1494
-     * (ie, what each returns for their name() function)
1495
-     * They're already available on EE_Registry::instance()->addons as properties,
1496
-     * where each property's name is the addon's classname,
1497
-     * So if you just want to get the addon by classname,
1498
-     * OR use the get_addon() method above.
1499
-     * PLEASE  NOTE:
1500
-     * addons with Fully Qualified Class Names
1501
-     * have had the namespace separators converted to underscores,
1502
-     * so a classname like Fully\Qualified\ClassName
1503
-     * would have been converted to Fully_Qualified_ClassName
1504
-     *
1505
-     * @return EE_Addon[] where the KEYS are the addon's name()
1506
-     */
1507
-    public function get_addons_by_name()
1508
-    {
1509
-        $addons = array();
1510
-        foreach ($this->addons as $addon) {
1511
-            $addons[ $addon->name() ] = $addon;
1512
-        }
1513
-        return $addons;
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1519
-     * a stale copy of it around
1520
-     *
1521
-     * @param string $model_name
1522
-     * @return \EEM_Base
1523
-     * @throws \EE_Error
1524
-     */
1525
-    public function reset_model($model_name)
1526
-    {
1527
-        $model_class_name = strpos($model_name, 'EEM_') !== 0
1528
-            ? "EEM_{$model_name}"
1529
-            : $model_name;
1530
-        if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1531
-            return null;
1532
-        }
1533
-        // get that model reset it and make sure we nuke the old reference to it
1534
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name
1535
-            && is_callable(
1536
-                array($model_class_name, 'reset')
1537
-            )) {
1538
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1539
-        } else {
1540
-            throw new EE_Error(
1541
-                sprintf(
1542
-                    esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1543
-                    $model_name
1544
-                )
1545
-            );
1546
-        }
1547
-        return $this->LIB->{$model_class_name};
1548
-    }
1549
-
1550
-
1551
-    /**
1552
-     * Resets the registry.
1553
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when
1554
-     * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1555
-     * - $_dependency_map
1556
-     * - $_class_abbreviations
1557
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1558
-     * - $REQ:  Still on the same request so no need to change.
1559
-     * - $CAP: There is no site specific state in the EE_Capability class.
1560
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1561
-     * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1562
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1563
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1564
-     *             switch or on the restore.
1565
-     * - $modules
1566
-     * - $shortcodes
1567
-     * - $widgets
1568
-     *
1569
-     * @param boolean $hard             [deprecated]
1570
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1571
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1572
-     *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1573
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1574
-     *                                  client
1575
-     *                                  code instead can just change the model context to a different blog id if
1576
-     *                                  necessary
1577
-     * @return EE_Registry
1578
-     * @throws InvalidInterfaceException
1579
-     * @throws InvalidDataTypeException
1580
-     * @throws EE_Error
1581
-     * @throws ReflectionException
1582
-     * @throws InvalidArgumentException
1583
-     */
1584
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1585
-    {
1586
-        $instance = self::instance();
1587
-        $instance->_cache_on = true;
1588
-        // reset some "special" classes
1589
-        EEH_Activation::reset();
1590
-        $hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1591
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1592
-        $instance->CART = null;
1593
-        $instance->MRM = null;
1594
-        $instance->AssetsRegistry = LoaderFactory::getLoader()->getShared(
1595
-            'EventEspresso\core\services\assets\Registry'
1596
-        );
1597
-        // messages reset
1598
-        EED_Messages::reset();
1599
-        // handle of objects cached on LIB
1600
-        foreach (array('LIB', 'modules') as $cache) {
1601
-            foreach ($instance->{$cache} as $class_name => $class) {
1602
-                if (self::_reset_and_unset_object($class, $reset_models)) {
1603
-                    unset($instance->{$cache}->{$class_name});
1604
-                }
1605
-            }
1606
-        }
1607
-        return $instance;
1608
-    }
1609
-
1610
-
1611
-    /**
1612
-     * if passed object implements ResettableInterface, then call it's reset() method
1613
-     * if passed object implements InterminableInterface, then return false,
1614
-     * to indicate that it should NOT be cleared from the Registry cache
1615
-     *
1616
-     * @param      $object
1617
-     * @param bool $reset_models
1618
-     * @return bool returns true if cached object should be unset
1619
-     */
1620
-    private static function _reset_and_unset_object($object, $reset_models)
1621
-    {
1622
-        if (! is_object($object)) {
1623
-            // don't unset anything that's not an object
1624
-            return false;
1625
-        }
1626
-        if ($object instanceof EED_Module) {
1627
-            $object::reset();
1628
-            // don't unset modules
1629
-            return false;
1630
-        }
1631
-        if ($object instanceof ResettableInterface) {
1632
-            if ($object instanceof EEM_Base) {
1633
-                if ($reset_models) {
1634
-                    $object->reset();
1635
-                    return true;
1636
-                }
1637
-                return false;
1638
-            }
1639
-            $object->reset();
1640
-            return true;
1641
-        }
1642
-        if (! $object instanceof InterminableInterface) {
1643
-            return true;
1644
-        }
1645
-        return false;
1646
-    }
1647
-
1648
-
1649
-    /**
1650
-     * Gets all the custom post type models defined
1651
-     *
1652
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1653
-     */
1654
-    public function cpt_models()
1655
-    {
1656
-        $cpt_models = array();
1657
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1658
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1659
-                $cpt_models[ $short_name ] = $classname;
1660
-            }
1661
-        }
1662
-        return $cpt_models;
1663
-    }
1664
-
1665
-
1666
-    /**
1667
-     * @return \EE_Config
1668
-     */
1669
-    public static function CFG()
1670
-    {
1671
-        return self::instance()->CFG;
1672
-    }
1673
-
1674
-
1675
-    /**
1676
-     * @deprecated 4.9.62.p
1677
-     * @param string $class_name
1678
-     * @return ReflectionClass
1679
-     * @throws ReflectionException
1680
-     * @throws InvalidDataTypeException
1681
-     */
1682
-    public function get_ReflectionClass($class_name)
1683
-    {
1684
-        return $this->mirror->getReflectionClass($class_name);
1685
-    }
26
+	/**
27
+	 * @var EE_Registry $_instance
28
+	 */
29
+	private static $_instance;
30
+
31
+	/**
32
+	 * @var EE_Dependency_Map $_dependency_map
33
+	 */
34
+	protected $_dependency_map;
35
+
36
+	/**
37
+	 * @var Mirror
38
+	 */
39
+	private $mirror;
40
+
41
+	/**
42
+	 * @var ClassInterfaceCache $class_cache
43
+	 */
44
+	private $class_cache;
45
+
46
+	/**
47
+	 * @var array $_class_abbreviations
48
+	 */
49
+	protected $_class_abbreviations = array();
50
+
51
+	/**
52
+	 * @var CommandBusInterface $BUS
53
+	 */
54
+	public $BUS;
55
+
56
+	/**
57
+	 * @var EE_Cart $CART
58
+	 */
59
+	public $CART;
60
+
61
+	/**
62
+	 * @var EE_Config $CFG
63
+	 */
64
+	public $CFG;
65
+
66
+	/**
67
+	 * @var EE_Network_Config $NET_CFG
68
+	 */
69
+	public $NET_CFG;
70
+
71
+	/**
72
+	 * StdClass object for storing library classes in
73
+	 *
74
+	 * @var RegistryContainer $LIB
75
+	 */
76
+	public $LIB;
77
+
78
+	/**
79
+	 * @var EE_Request_Handler $REQ
80
+	 */
81
+	public $REQ;
82
+
83
+	/**
84
+	 * @var EE_Session $SSN
85
+	 */
86
+	public $SSN;
87
+
88
+	/**
89
+	 * @since 4.5.0
90
+	 * @var EE_Capabilities $CAP
91
+	 */
92
+	public $CAP;
93
+
94
+	/**
95
+	 * @since 4.9.0
96
+	 * @var EE_Message_Resource_Manager $MRM
97
+	 */
98
+	public $MRM;
99
+
100
+	/**
101
+	 * @var Registry $AssetsRegistry
102
+	 */
103
+	public $AssetsRegistry;
104
+
105
+	/**
106
+	 * StdClass object for holding addons which have registered themselves to work with EE core
107
+	 *
108
+	 * @var EE_Addon[] $addons
109
+	 */
110
+	public $addons;
111
+
112
+	/**
113
+	 * keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
114
+	 *
115
+	 * @var EEM_Base[] $models
116
+	 */
117
+	public $models = array();
118
+
119
+	/**
120
+	 * @var EED_Module[] $modules
121
+	 */
122
+	public $modules;
123
+
124
+	/**
125
+	 * @var EES_Shortcode[] $shortcodes
126
+	 */
127
+	public $shortcodes;
128
+
129
+	/**
130
+	 * @var WP_Widget[] $widgets
131
+	 */
132
+	public $widgets;
133
+
134
+	/**
135
+	 * this is an array of all implemented model names (i.e. not the parent abstract models, or models
136
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
137
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
138
+	 * classnames (eg "EEM_Event")
139
+	 *
140
+	 * @var array $non_abstract_db_models
141
+	 */
142
+	public $non_abstract_db_models = array();
143
+
144
+	/**
145
+	 * internationalization for JS strings
146
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = esc_html__( 'string to translate.', 'event_espresso' );
147
+	 *    in js file:  var translatedString = eei18n.string_key;
148
+	 *
149
+	 * @var array $i18n_js_strings
150
+	 */
151
+	public static $i18n_js_strings = array();
152
+
153
+	/**
154
+	 * $main_file - path to espresso.php
155
+	 *
156
+	 * @var array $main_file
157
+	 */
158
+	public $main_file;
159
+
160
+	/**
161
+	 * array of ReflectionClass objects where the key is the class name
162
+	 *
163
+	 * @deprecated 4.9.62.p
164
+	 * @var ReflectionClass[] $_reflectors
165
+	 */
166
+	public $_reflectors;
167
+
168
+	/**
169
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
170
+	 *
171
+	 * @var boolean $_cache_on
172
+	 */
173
+	protected $_cache_on = true;
174
+
175
+	/**
176
+	 * @var ObjectIdentifier
177
+	 */
178
+	private $object_identifier;
179
+
180
+
181
+	/**
182
+	 * @singleton method used to instantiate class object
183
+	 * @param EE_Dependency_Map|null   $dependency_map
184
+	 * @param Mirror|null              $mirror
185
+	 * @param ClassInterfaceCache|null $class_cache
186
+	 * @param ObjectIdentifier|null    $object_identifier
187
+	 * @return EE_Registry instance
188
+	 */
189
+	public static function instance(
190
+		EE_Dependency_Map $dependency_map = null,
191
+		Mirror $mirror = null,
192
+		ClassInterfaceCache $class_cache = null,
193
+		ObjectIdentifier $object_identifier = null
194
+	) {
195
+		// check if class object is instantiated
196
+		if (! self::$_instance instanceof EE_Registry
197
+			&& $dependency_map instanceof EE_Dependency_Map
198
+			&& $mirror instanceof Mirror
199
+			&& $class_cache instanceof ClassInterfaceCache
200
+			&& $object_identifier instanceof ObjectIdentifier
201
+		) {
202
+			self::$_instance = new self(
203
+				$dependency_map,
204
+				$mirror,
205
+				$class_cache,
206
+				$object_identifier
207
+			);
208
+		}
209
+		return self::$_instance;
210
+	}
211
+
212
+
213
+	/**
214
+	 * protected constructor to prevent direct creation
215
+	 *
216
+	 * @Constructor
217
+	 * @param  EE_Dependency_Map  $dependency_map
218
+	 * @param Mirror              $mirror
219
+	 * @param ClassInterfaceCache $class_cache
220
+	 * @param ObjectIdentifier    $object_identifier
221
+	 */
222
+	protected function __construct(
223
+		EE_Dependency_Map $dependency_map,
224
+		Mirror $mirror,
225
+		ClassInterfaceCache $class_cache,
226
+		ObjectIdentifier $object_identifier
227
+	) {
228
+		$this->_dependency_map = $dependency_map;
229
+		$this->mirror = $mirror;
230
+		$this->class_cache = $class_cache;
231
+		$this->object_identifier = $object_identifier;
232
+		// $registry_container = new RegistryContainer();
233
+		$this->LIB = new RegistryContainer();
234
+		$this->addons = new RegistryContainer();
235
+		$this->modules = new RegistryContainer();
236
+		$this->shortcodes = new RegistryContainer();
237
+		$this->widgets = new RegistryContainer();
238
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
239
+	}
240
+
241
+
242
+	/**
243
+	 * initialize
244
+	 *
245
+	 * @throws OutOfBoundsException
246
+	 * @throws InvalidArgumentException
247
+	 * @throws InvalidInterfaceException
248
+	 * @throws InvalidDataTypeException
249
+	 * @throws EE_Error
250
+	 * @throws ReflectionException
251
+	 */
252
+	public function initialize()
253
+	{
254
+		$this->_class_abbreviations = apply_filters(
255
+			'FHEE__EE_Registry____construct___class_abbreviations',
256
+			array(
257
+				'EE_Config'                                       => 'CFG',
258
+				'EE_Session'                                      => 'SSN',
259
+				'EE_Capabilities'                                 => 'CAP',
260
+				'EE_Cart'                                         => 'CART',
261
+				'EE_Network_Config'                               => 'NET_CFG',
262
+				'EE_Request_Handler'                              => 'REQ',
263
+				'EE_Message_Resource_Manager'                     => 'MRM',
264
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
265
+				'EventEspresso\core\services\assets\Registry'     => 'AssetsRegistry',
266
+			)
267
+		);
268
+		$this->load_core('Base', array(), true);
269
+		// add our request and response objects to the cache
270
+		$request_loader = $this->_dependency_map->class_loader(
271
+			'EventEspresso\core\services\request\Request'
272
+		);
273
+		$this->_set_cached_class(
274
+			$request_loader(),
275
+			'EventEspresso\core\services\request\Request'
276
+		);
277
+		$response_loader = $this->_dependency_map->class_loader(
278
+			'EventEspresso\core\services\request\Response'
279
+		);
280
+		$this->_set_cached_class(
281
+			$response_loader(),
282
+			'EventEspresso\core\services\request\Response'
283
+		);
284
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
285
+	}
286
+
287
+
288
+	/**
289
+	 * @return void
290
+	 */
291
+	public function init()
292
+	{
293
+		// Get current page protocol
294
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
295
+		// Output admin-ajax.php URL with same protocol as current page
296
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
297
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
298
+	}
299
+
300
+
301
+	/**
302
+	 * localize_i18n_js_strings
303
+	 *
304
+	 * @return string
305
+	 */
306
+	public static function localize_i18n_js_strings()
307
+	{
308
+		$i18n_js_strings = (array) self::$i18n_js_strings;
309
+		foreach ($i18n_js_strings as $key => $value) {
310
+			if (is_scalar($value)) {
311
+				$i18n_js_strings[ $key ] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
312
+			}
313
+		}
314
+		return '/* <![CDATA[ */ var eei18n = ' . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
315
+	}
316
+
317
+
318
+	/**
319
+	 * @param mixed string | EED_Module $module
320
+	 * @throws OutOfBoundsException
321
+	 * @throws InvalidArgumentException
322
+	 * @throws InvalidInterfaceException
323
+	 * @throws InvalidDataTypeException
324
+	 * @throws EE_Error
325
+	 * @throws ReflectionException
326
+	 */
327
+	public function add_module($module)
328
+	{
329
+		if ($module instanceof EED_Module) {
330
+			$module_class = get_class($module);
331
+			$this->modules->{$module_class} = $module;
332
+		} else {
333
+			if (! class_exists('EE_Module_Request_Router', false)) {
334
+				$this->load_core('Module_Request_Router');
335
+			}
336
+			EE_Module_Request_Router::module_factory($module);
337
+		}
338
+	}
339
+
340
+
341
+	/**
342
+	 * @param string $module_name
343
+	 * @return mixed EED_Module | NULL
344
+	 */
345
+	public function get_module($module_name = '')
346
+	{
347
+		return isset($this->modules->{$module_name})
348
+			? $this->modules->{$module_name}
349
+			: null;
350
+	}
351
+
352
+
353
+	/**
354
+	 * loads core classes - must be singletons
355
+	 *
356
+	 * @param string $class_name - simple class name ie: session
357
+	 * @param mixed  $arguments
358
+	 * @param bool   $load_only
359
+	 * @return mixed
360
+	 * @throws InvalidInterfaceException
361
+	 * @throws InvalidDataTypeException
362
+	 * @throws EE_Error
363
+	 * @throws ReflectionException
364
+	 * @throws InvalidArgumentException
365
+	 */
366
+	public function load_core($class_name, $arguments = array(), $load_only = false)
367
+	{
368
+		$core_paths = apply_filters(
369
+			'FHEE__EE_Registry__load_core__core_paths',
370
+			array(
371
+				EE_CORE,
372
+				EE_ADMIN,
373
+				EE_CPTS,
374
+				EE_CORE . 'data_migration_scripts' . DS,
375
+				EE_CORE . 'capabilities' . DS,
376
+				EE_CORE . 'request_stack' . DS,
377
+				EE_CORE . 'middleware' . DS,
378
+			)
379
+		);
380
+		// retrieve instantiated class
381
+		return $this->_load(
382
+			$core_paths,
383
+			'EE_',
384
+			$class_name,
385
+			'core',
386
+			$arguments,
387
+			false,
388
+			true,
389
+			$load_only
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * loads service classes
396
+	 *
397
+	 * @param string $class_name - simple class name ie: session
398
+	 * @param mixed  $arguments
399
+	 * @param bool   $load_only
400
+	 * @return mixed
401
+	 * @throws InvalidInterfaceException
402
+	 * @throws InvalidDataTypeException
403
+	 * @throws EE_Error
404
+	 * @throws ReflectionException
405
+	 * @throws InvalidArgumentException
406
+	 */
407
+	public function load_service($class_name, $arguments = array(), $load_only = false)
408
+	{
409
+		$service_paths = apply_filters(
410
+			'FHEE__EE_Registry__load_service__service_paths',
411
+			array(
412
+				EE_CORE . 'services' . DS,
413
+			)
414
+		);
415
+		// retrieve instantiated class
416
+		return $this->_load(
417
+			$service_paths,
418
+			'EE_',
419
+			$class_name,
420
+			'class',
421
+			$arguments,
422
+			false,
423
+			true,
424
+			$load_only
425
+		);
426
+	}
427
+
428
+
429
+	/**
430
+	 * loads data_migration_scripts
431
+	 *
432
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
433
+	 * @param mixed  $arguments
434
+	 * @return EE_Data_Migration_Script_Base|mixed
435
+	 * @throws InvalidInterfaceException
436
+	 * @throws InvalidDataTypeException
437
+	 * @throws EE_Error
438
+	 * @throws ReflectionException
439
+	 * @throws InvalidArgumentException
440
+	 */
441
+	public function load_dms($class_name, $arguments = array())
442
+	{
443
+		// retrieve instantiated class
444
+		return $this->_load(
445
+			EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(),
446
+			'EE_DMS_',
447
+			$class_name,
448
+			'dms',
449
+			$arguments,
450
+			false,
451
+			false
452
+		);
453
+	}
454
+
455
+
456
+	/**
457
+	 * loads object creating classes - must be singletons
458
+	 *
459
+	 * @param string $class_name - simple class name ie: attendee
460
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
461
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to
462
+	 *                           instantiate
463
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then
464
+	 *                           set this to FALSE (ie. when instantiating model objects from client in a loop)
465
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate
466
+	 *                           (default)
467
+	 * @return EE_Base_Class | bool
468
+	 * @throws InvalidInterfaceException
469
+	 * @throws InvalidDataTypeException
470
+	 * @throws EE_Error
471
+	 * @throws ReflectionException
472
+	 * @throws InvalidArgumentException
473
+	 */
474
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
475
+	{
476
+		$paths = apply_filters(
477
+			'FHEE__EE_Registry__load_class__paths',
478
+			array(
479
+				EE_CORE,
480
+				EE_CLASSES,
481
+				EE_BUSINESS,
482
+			)
483
+		);
484
+		// retrieve instantiated class
485
+		return $this->_load(
486
+			$paths,
487
+			'EE_',
488
+			$class_name,
489
+			'class',
490
+			$arguments,
491
+			$from_db,
492
+			$cache,
493
+			$load_only
494
+		);
495
+	}
496
+
497
+
498
+	/**
499
+	 * loads helper classes - must be singletons
500
+	 *
501
+	 * @param string $class_name - simple class name ie: price
502
+	 * @param mixed  $arguments
503
+	 * @param bool   $load_only
504
+	 * @return EEH_Base | bool
505
+	 * @throws InvalidInterfaceException
506
+	 * @throws InvalidDataTypeException
507
+	 * @throws EE_Error
508
+	 * @throws ReflectionException
509
+	 * @throws InvalidArgumentException
510
+	 */
511
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
512
+	{
513
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
514
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
515
+		// retrieve instantiated class
516
+		return $this->_load(
517
+			$helper_paths,
518
+			'EEH_',
519
+			$class_name,
520
+			'helper',
521
+			$arguments,
522
+			false,
523
+			true,
524
+			$load_only
525
+		);
526
+	}
527
+
528
+
529
+	/**
530
+	 * loads core classes - must be singletons
531
+	 *
532
+	 * @param string $class_name - simple class name ie: session
533
+	 * @param mixed  $arguments
534
+	 * @param bool   $load_only
535
+	 * @param bool   $cache      whether to cache the object or not.
536
+	 * @return mixed
537
+	 * @throws InvalidInterfaceException
538
+	 * @throws InvalidDataTypeException
539
+	 * @throws EE_Error
540
+	 * @throws ReflectionException
541
+	 * @throws InvalidArgumentException
542
+	 */
543
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
544
+	{
545
+		$paths = array(
546
+			EE_LIBRARIES,
547
+			EE_LIBRARIES . 'messages' . DS,
548
+			EE_LIBRARIES . 'shortcodes' . DS,
549
+			EE_LIBRARIES . 'qtips' . DS,
550
+			EE_LIBRARIES . 'payment_methods' . DS,
551
+		);
552
+		// retrieve instantiated class
553
+		return $this->_load(
554
+			$paths,
555
+			'EE_',
556
+			$class_name,
557
+			'lib',
558
+			$arguments,
559
+			false,
560
+			$cache,
561
+			$load_only
562
+		);
563
+	}
564
+
565
+
566
+	/**
567
+	 * loads model classes - must be singletons
568
+	 *
569
+	 * @param string $class_name - simple class name ie: price
570
+	 * @param mixed  $arguments
571
+	 * @param bool   $load_only
572
+	 * @return EEM_Base | bool
573
+	 * @throws InvalidInterfaceException
574
+	 * @throws InvalidDataTypeException
575
+	 * @throws EE_Error
576
+	 * @throws ReflectionException
577
+	 * @throws InvalidArgumentException
578
+	 */
579
+	public function load_model($class_name, $arguments = array(), $load_only = false)
580
+	{
581
+		$paths = apply_filters(
582
+			'FHEE__EE_Registry__load_model__paths',
583
+			array(
584
+				EE_MODELS,
585
+				EE_CORE,
586
+			)
587
+		);
588
+		// retrieve instantiated class
589
+		return $this->_load(
590
+			$paths,
591
+			'EEM_',
592
+			$class_name,
593
+			'model',
594
+			$arguments,
595
+			false,
596
+			true,
597
+			$load_only
598
+		);
599
+	}
600
+
601
+
602
+	/**
603
+	 * loads model classes - must be singletons
604
+	 *
605
+	 * @param string $class_name - simple class name ie: price
606
+	 * @param mixed  $arguments
607
+	 * @param bool   $load_only
608
+	 * @return mixed | bool
609
+	 * @throws InvalidInterfaceException
610
+	 * @throws InvalidDataTypeException
611
+	 * @throws EE_Error
612
+	 * @throws ReflectionException
613
+	 * @throws InvalidArgumentException
614
+	 */
615
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
616
+	{
617
+		$paths = array(
618
+			EE_MODELS . 'fields' . DS,
619
+			EE_MODELS . 'helpers' . DS,
620
+			EE_MODELS . 'relations' . DS,
621
+			EE_MODELS . 'strategies' . DS,
622
+		);
623
+		// retrieve instantiated class
624
+		return $this->_load(
625
+			$paths,
626
+			'EE_',
627
+			$class_name,
628
+			'',
629
+			$arguments,
630
+			false,
631
+			true,
632
+			$load_only
633
+		);
634
+	}
635
+
636
+
637
+	/**
638
+	 * Determines if $model_name is the name of an actual EE model.
639
+	 *
640
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
641
+	 * @return boolean
642
+	 */
643
+	public function is_model_name($model_name)
644
+	{
645
+		return isset($this->models[ $model_name ]);
646
+	}
647
+
648
+
649
+	/**
650
+	 * generic class loader
651
+	 *
652
+	 * @param string $path_to_file - directory path to file location, not including filename
653
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
654
+	 * @param string $type         - file type - core? class? helper? model?
655
+	 * @param mixed  $arguments
656
+	 * @param bool   $load_only
657
+	 * @return mixed
658
+	 * @throws InvalidInterfaceException
659
+	 * @throws InvalidDataTypeException
660
+	 * @throws EE_Error
661
+	 * @throws ReflectionException
662
+	 * @throws InvalidArgumentException
663
+	 */
664
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
665
+	{
666
+		// retrieve instantiated class
667
+		return $this->_load(
668
+			$path_to_file,
669
+			'',
670
+			$file_name,
671
+			$type,
672
+			$arguments,
673
+			false,
674
+			true,
675
+			$load_only
676
+		);
677
+	}
678
+
679
+
680
+	/**
681
+	 * @param string $path_to_file - directory path to file location, not including filename
682
+	 * @param string $class_name   - full class name  ie:  My_Class
683
+	 * @param string $type         - file type - core? class? helper? model?
684
+	 * @param mixed  $arguments
685
+	 * @param bool   $load_only
686
+	 * @return bool|EE_Addon|object
687
+	 * @throws InvalidInterfaceException
688
+	 * @throws InvalidDataTypeException
689
+	 * @throws EE_Error
690
+	 * @throws ReflectionException
691
+	 * @throws InvalidArgumentException
692
+	 */
693
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
694
+	{
695
+		// retrieve instantiated class
696
+		return $this->_load(
697
+			$path_to_file,
698
+			'addon',
699
+			$class_name,
700
+			$type,
701
+			$arguments,
702
+			false,
703
+			true,
704
+			$load_only
705
+		);
706
+	}
707
+
708
+
709
+	/**
710
+	 * instantiates, caches, and automatically resolves dependencies
711
+	 * for classes that use a Fully Qualified Class Name.
712
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
713
+	 * then you need to use one of the existing load_*() methods
714
+	 * which can resolve the classname and filepath from the passed arguments
715
+	 *
716
+	 * @param bool|string $class_name   Fully Qualified Class Name
717
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
718
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
719
+	 * @param bool        $from_db      some classes are instantiated from the db
720
+	 *                                  and thus call a different method to instantiate
721
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
722
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
723
+	 * @return bool|null|mixed          null = failure to load or instantiate class object.
724
+	 *                                  object = class loaded and instantiated successfully.
725
+	 *                                  bool = fail or success when $load_only is true
726
+	 * @throws InvalidInterfaceException
727
+	 * @throws InvalidDataTypeException
728
+	 * @throws EE_Error
729
+	 * @throws ReflectionException
730
+	 * @throws InvalidArgumentException
731
+	 */
732
+	public function create(
733
+		$class_name = false,
734
+		$arguments = array(),
735
+		$cache = false,
736
+		$from_db = false,
737
+		$load_only = false,
738
+		$addon = false
739
+	) {
740
+		$class_name = ltrim($class_name, '\\');
741
+		$class_name = $this->class_cache->getFqnForAlias($class_name);
742
+		$class_exists = $this->loadOrVerifyClassExists($class_name, $arguments);
743
+		// if a non-FQCN was passed, then
744
+		// verifyClassExists() might return an object
745
+		// or it could return null if the class just could not be found anywhere
746
+		if ($class_exists instanceof $class_name || $class_exists === null) {
747
+			// either way, return the results
748
+			return $class_exists;
749
+		}
750
+		$class_name = $class_exists;
751
+		// if we're only loading the class and it already exists, then let's just return true immediately
752
+		if ($load_only) {
753
+			return true;
754
+		}
755
+		$addon = $addon ? 'addon' : '';
756
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
757
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
758
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
759
+		if ($this->_cache_on && $cache && ! $load_only) {
760
+			// return object if it's already cached
761
+			$cached_class = $this->_get_cached_class($class_name, $addon, $arguments);
762
+			if ($cached_class !== null) {
763
+				return $cached_class;
764
+			}
765
+		}// obtain the loader method from the dependency map
766
+		$loader = $this->_dependency_map->class_loader($class_name);// instantiate the requested object
767
+		if ($loader instanceof Closure) {
768
+			$class_obj = $loader($arguments);
769
+		} else {
770
+			if ($loader && method_exists($this, $loader)) {
771
+				$class_obj = $this->{$loader}($class_name, $arguments);
772
+			} else {
773
+				$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
774
+			}
775
+		}
776
+		if (($this->_cache_on && $cache) || $this->get_class_abbreviation($class_name, '')) {
777
+			// save it for later... kinda like gum  { : $
778
+			$this->_set_cached_class(
779
+				$class_obj,
780
+				$class_name,
781
+				$addon,
782
+				$from_db,
783
+				$arguments
784
+			);
785
+		}
786
+		$this->_cache_on = true;
787
+		return $class_obj;
788
+	}
789
+
790
+
791
+	/**
792
+	 * Recursively checks that a class exists and potentially attempts to load classes with non-FQCNs
793
+	 *
794
+	 * @param string|object $class_name
795
+	 * @param array         $arguments
796
+	 * @param int           $attempt
797
+	 * @return mixed
798
+	 */
799
+	private function loadOrVerifyClassExists($class_name, array $arguments, $attempt = 1)
800
+	{
801
+		if (is_object($class_name) || class_exists($class_name)) {
802
+			return $class_name;
803
+		}
804
+		switch ($attempt) {
805
+			case 1:
806
+				// if it's a FQCN then maybe the class is registered with a preceding \
807
+				$class_name = strpos($class_name, '\\') !== false
808
+					? '\\' . ltrim($class_name, '\\')
809
+					: $class_name;
810
+				break;
811
+			case 2:
812
+				//
813
+				$loader = $this->_dependency_map->class_loader($class_name);
814
+				if ($loader && method_exists($this, $loader)) {
815
+					return $this->{$loader}($class_name, $arguments);
816
+				}
817
+				break;
818
+			case 3:
819
+			default:
820
+				return null;
821
+		}
822
+		$attempt++;
823
+		return $this->loadOrVerifyClassExists($class_name, $arguments, $attempt);
824
+	}
825
+
826
+
827
+	/**
828
+	 * instantiates, caches, and injects dependencies for classes
829
+	 *
830
+	 * @param array       $file_paths   an array of paths to folders to look in
831
+	 * @param string      $class_prefix EE  or EEM or... ???
832
+	 * @param bool|string $class_name   $class name
833
+	 * @param string      $type         file type - core? class? helper? model?
834
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
835
+	 * @param bool        $from_db      some classes are instantiated from the db
836
+	 *                                  and thus call a different method to instantiate
837
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
838
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
839
+	 * @return bool|null|object null = failure to load or instantiate class object.
840
+	 *                                  object = class loaded and instantiated successfully.
841
+	 *                                  bool = fail or success when $load_only is true
842
+	 * @throws EE_Error
843
+	 * @throws ReflectionException
844
+	 * @throws InvalidInterfaceException
845
+	 * @throws InvalidDataTypeException
846
+	 * @throws InvalidArgumentException
847
+	 */
848
+	protected function _load(
849
+		$file_paths = array(),
850
+		$class_prefix = 'EE_',
851
+		$class_name = false,
852
+		$type = 'class',
853
+		$arguments = array(),
854
+		$from_db = false,
855
+		$cache = true,
856
+		$load_only = false
857
+	) {
858
+		$class_name = ltrim($class_name, '\\');
859
+		// strip php file extension
860
+		$class_name = str_replace('.php', '', trim($class_name));
861
+		// does the class have a prefix ?
862
+		if (! empty($class_prefix) && $class_prefix !== 'addon') {
863
+			// make sure $class_prefix is uppercase
864
+			$class_prefix = strtoupper(trim($class_prefix));
865
+			// add class prefix ONCE!!!
866
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
867
+		}
868
+		$class_name = $this->class_cache->getFqnForAlias($class_name);
869
+		$class_exists = class_exists($class_name, false);
870
+		// if we're only loading the class and it already exists, then let's just return true immediately
871
+		if ($load_only && $class_exists) {
872
+			return true;
873
+		}
874
+		$arguments = is_array($arguments) ? $arguments : array($arguments);
875
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
876
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
877
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
878
+		if ($this->_cache_on && $cache && ! $load_only) {
879
+			// return object if it's already cached
880
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix, $arguments);
881
+			if ($cached_class !== null) {
882
+				return $cached_class;
883
+			}
884
+		}
885
+		// if the class doesn't already exist.. then we need to try and find the file and load it
886
+		if (! $class_exists) {
887
+			// get full path to file
888
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
889
+			// load the file
890
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
891
+			// if we are only loading a file but NOT instantiating an object
892
+			// then return boolean for whether class was loaded or not
893
+			if ($load_only) {
894
+				return $loaded;
895
+			}
896
+			// if an object was expected but loading failed, then return nothing
897
+			if (! $loaded) {
898
+				return null;
899
+			}
900
+		}
901
+		// instantiate the requested object
902
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
903
+		if ($this->_cache_on && $cache) {
904
+			// save it for later... kinda like gum  { : $
905
+			$this->_set_cached_class(
906
+				$class_obj,
907
+				$class_name,
908
+				$class_prefix,
909
+				$from_db,
910
+				$arguments
911
+			);
912
+		}
913
+		$this->_cache_on = true;
914
+		return $class_obj;
915
+	}
916
+
917
+
918
+	/**
919
+	 * @param string $class_name
920
+	 * @param string $default have to specify something, but not anything that will conflict
921
+	 * @return mixed|string
922
+	 */
923
+	protected function get_class_abbreviation($class_name, $default = 'FANCY_BATMAN_PANTS')
924
+	{
925
+		return isset($this->_class_abbreviations[ $class_name ])
926
+			? $this->_class_abbreviations[ $class_name ]
927
+			: $default;
928
+	}
929
+
930
+
931
+	/**
932
+	 * attempts to find a cached version of the requested class
933
+	 * by looking in the following places:
934
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
935
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
936
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
937
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
938
+	 *
939
+	 * @param string $class_name
940
+	 * @param string $class_prefix
941
+	 * @param array  $arguments
942
+	 * @return mixed
943
+	 */
944
+	protected function _get_cached_class(
945
+		$class_name,
946
+		$class_prefix = '',
947
+		$arguments = array()
948
+	) {
949
+		if ($class_name === 'EE_Registry') {
950
+			return $this;
951
+		}
952
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
953
+		// check if class has already been loaded, and return it if it has been
954
+		if (isset($this->{$class_abbreviation})) {
955
+			return $this->{$class_abbreviation};
956
+		}
957
+		$class_name = str_replace('\\', '_', $class_name);
958
+		if (isset($this->{$class_name})) {
959
+			return $this->{$class_name};
960
+		}
961
+		if ($class_prefix === 'addon' && isset($this->addons->{$class_name})) {
962
+			return $this->addons->{$class_name};
963
+		}
964
+		$object_identifier = $this->object_identifier->getIdentifier($class_name, $arguments);
965
+		if (isset($this->LIB->{$object_identifier})) {
966
+			return $this->LIB->{$object_identifier};
967
+		}
968
+		foreach ($this->LIB as $key => $object) {
969
+			if (// request does not contain new arguments and therefore no args identifier
970
+				! $this->object_identifier->hasArguments($object_identifier)
971
+				// but previously cached class with args was found
972
+				&& $this->object_identifier->fqcnMatchesObjectIdentifier($class_name, $key)
973
+			) {
974
+				return $object;
975
+			}
976
+		}
977
+		return null;
978
+	}
979
+
980
+
981
+	/**
982
+	 * removes a cached version of the requested class
983
+	 *
984
+	 * @param string  $class_name
985
+	 * @param boolean $addon
986
+	 * @param array   $arguments
987
+	 * @return boolean
988
+	 */
989
+	public function clear_cached_class(
990
+		$class_name,
991
+		$addon = false,
992
+		$arguments = array()
993
+	) {
994
+		$class_abbreviation = $this->get_class_abbreviation($class_name);
995
+		// check if class has already been loaded, and return it if it has been
996
+		if (isset($this->{$class_abbreviation})) {
997
+			$this->{$class_abbreviation} = null;
998
+			return true;
999
+		}
1000
+		$class_name = str_replace('\\', '_', $class_name);
1001
+		if (isset($this->{$class_name})) {
1002
+			$this->{$class_name} = null;
1003
+			return true;
1004
+		}
1005
+		if ($addon && isset($this->addons->{$class_name})) {
1006
+			unset($this->addons->{$class_name});
1007
+			return true;
1008
+		}
1009
+		$class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1010
+		if (isset($this->LIB->{$class_name})) {
1011
+			unset($this->LIB->{$class_name});
1012
+			return true;
1013
+		}
1014
+		return false;
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * _set_cached_class
1020
+	 * attempts to cache the instantiated class locally
1021
+	 * in one of the following places, in the following order:
1022
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1023
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1024
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1025
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1026
+	 *
1027
+	 * @param object $class_obj
1028
+	 * @param string $class_name
1029
+	 * @param string $class_prefix
1030
+	 * @param bool   $from_db
1031
+	 * @param array  $arguments
1032
+	 * @return void
1033
+	 */
1034
+	protected function _set_cached_class(
1035
+		$class_obj,
1036
+		$class_name,
1037
+		$class_prefix = '',
1038
+		$from_db = false,
1039
+		$arguments = array()
1040
+	) {
1041
+		if ($class_name === 'EE_Registry' || empty($class_obj)) {
1042
+			return;
1043
+		}
1044
+		// return newly instantiated class
1045
+		$class_abbreviation = $this->get_class_abbreviation($class_name, '');
1046
+		if ($class_abbreviation) {
1047
+			$this->{$class_abbreviation} = $class_obj;
1048
+			return;
1049
+		}
1050
+		$class_name = str_replace('\\', '_', $class_name);
1051
+		if (property_exists($this, $class_name)) {
1052
+			$this->{$class_name} = $class_obj;
1053
+			return;
1054
+		}
1055
+		if ($class_prefix === 'addon') {
1056
+			$this->addons->{$class_name} = $class_obj;
1057
+			return;
1058
+		}
1059
+		if (! $from_db) {
1060
+			$class_name = $this->object_identifier->getIdentifier($class_name, $arguments);
1061
+			$this->LIB->{$class_name} = $class_obj;
1062
+		}
1063
+	}
1064
+
1065
+
1066
+	/**
1067
+	 * attempts to find a full valid filepath for the requested class.
1068
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
1069
+	 * then returns that path if the target file has been found and is readable
1070
+	 *
1071
+	 * @param string $class_name
1072
+	 * @param string $type
1073
+	 * @param array  $file_paths
1074
+	 * @return string | bool
1075
+	 */
1076
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
1077
+	{
1078
+		// make sure $file_paths is an array
1079
+		$file_paths = is_array($file_paths)
1080
+			? $file_paths
1081
+			: array($file_paths);
1082
+		// cycle thru paths
1083
+		foreach ($file_paths as $key => $file_path) {
1084
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
1085
+			$file_path = $file_path
1086
+				? str_replace(array('/', '\\'), DS, $file_path)
1087
+				: EE_CLASSES;
1088
+			// prep file type
1089
+			$type = ! empty($type)
1090
+				? trim($type, '.') . '.'
1091
+				: '';
1092
+			// build full file path
1093
+			$file_paths[ $key ] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
1094
+			// does the file exist and can be read ?
1095
+			if (is_readable($file_paths[ $key ])) {
1096
+				return $file_paths[ $key ];
1097
+			}
1098
+		}
1099
+		return false;
1100
+	}
1101
+
1102
+
1103
+	/**
1104
+	 * basically just performs a require_once()
1105
+	 * but with some error handling
1106
+	 *
1107
+	 * @param  string $path
1108
+	 * @param  string $class_name
1109
+	 * @param  string $type
1110
+	 * @param  array  $file_paths
1111
+	 * @return bool
1112
+	 * @throws EE_Error
1113
+	 * @throws ReflectionException
1114
+	 */
1115
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
1116
+	{
1117
+		$this->resolve_legacy_class_parent($class_name);
1118
+		// don't give up! you gotta...
1119
+		try {
1120
+			// does the file exist and can it be read ?
1121
+			if (! $path) {
1122
+				// just in case the file has already been autoloaded,
1123
+				// but discrepancies in the naming schema are preventing it from
1124
+				// being loaded via one of the EE_Registry::load_*() methods,
1125
+				// then let's try one last hail mary before throwing an exception
1126
+				// and call class_exists() again, but with autoloading turned ON
1127
+				if (class_exists($class_name)) {
1128
+					return true;
1129
+				}
1130
+				// so sorry, can't find the file
1131
+				throw new EE_Error(
1132
+					sprintf(
1133
+						esc_html__(
1134
+							'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s',
1135
+							'event_espresso'
1136
+						),
1137
+						trim($type, '.'),
1138
+						$class_name,
1139
+						'<br />' . implode(',<br />', $file_paths)
1140
+					)
1141
+				);
1142
+			}
1143
+			// get the file
1144
+			require_once($path);
1145
+			// if the class isn't already declared somewhere
1146
+			if (class_exists($class_name, false) === false) {
1147
+				// so sorry, not a class
1148
+				throw new EE_Error(
1149
+					sprintf(
1150
+						esc_html__(
1151
+							'The %s file %s does not appear to contain the %s Class.',
1152
+							'event_espresso'
1153
+						),
1154
+						$type,
1155
+						$path,
1156
+						$class_name
1157
+					)
1158
+				);
1159
+			}
1160
+		} catch (EE_Error $e) {
1161
+			$e->get_error();
1162
+			return false;
1163
+		}
1164
+		return true;
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * Some of our legacy classes that extended a parent class would simply use a require() statement
1170
+	 * before their class declaration in order to ensure that the parent class was loaded.
1171
+	 * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
1172
+	 * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
1173
+	 *
1174
+	 * @param string $class_name
1175
+	 */
1176
+	protected function resolve_legacy_class_parent($class_name = '')
1177
+	{
1178
+		try {
1179
+			$legacy_parent_class_map = array(
1180
+				'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php',
1181
+			);
1182
+			if (isset($legacy_parent_class_map[ $class_name ])) {
1183
+				require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[ $class_name ];
1184
+			}
1185
+		} catch (Exception $exception) {
1186
+		}
1187
+	}
1188
+
1189
+
1190
+	/**
1191
+	 * _create_object
1192
+	 * Attempts to instantiate the requested class via any of the
1193
+	 * commonly used instantiation methods employed throughout EE.
1194
+	 * The priority for instantiation is as follows:
1195
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
1196
+	 *        - model objects via their 'new_instance_from_db' method
1197
+	 *        - model objects via their 'new_instance' method
1198
+	 *        - "singleton" classes" via their 'instance' method
1199
+	 *    - standard instantiable classes via their __constructor
1200
+	 * Prior to instantiation, if the classname exists in the dependency_map,
1201
+	 * then the constructor for the requested class will be examined to determine
1202
+	 * if any dependencies exist, and if they can be injected.
1203
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1204
+	 *
1205
+	 * @param string $class_name
1206
+	 * @param array  $arguments
1207
+	 * @param string $type
1208
+	 * @param bool   $from_db
1209
+	 * @return null|object|bool
1210
+	 * @throws InvalidArgumentException
1211
+	 * @throws InvalidInterfaceException
1212
+	 * @throws EE_Error
1213
+	 * @throws ReflectionException
1214
+	 * @throws InvalidDataTypeException
1215
+	 */
1216
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
1217
+	{
1218
+		// create reflection
1219
+		$reflector = $this->mirror->getReflectionClass($class_name);
1220
+		// make sure arguments are an array
1221
+		$arguments = is_array($arguments)
1222
+			? $arguments
1223
+			: array($arguments);
1224
+		// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
1225
+		// else wrap it in an additional array so that it doesn't get split into multiple parameters
1226
+		$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
1227
+			? $arguments
1228
+			: array($arguments);
1229
+		// attempt to inject dependencies ?
1230
+		if ($this->_dependency_map->has($class_name)) {
1231
+			$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
1232
+		}
1233
+		// instantiate the class if possible
1234
+		if ($reflector->isAbstract()) {
1235
+			// nothing to instantiate, loading file was enough
1236
+			// does not throw an exception so $instantiation_mode is unused
1237
+			// $instantiation_mode = "1) no constructor abstract class";
1238
+			return true;
1239
+		}
1240
+		if (empty($arguments)
1241
+			&& $this->mirror->getConstructorFromReflection($reflector) === null
1242
+			&& $reflector->isInstantiable()
1243
+		) {
1244
+			// no constructor = static methods only... nothing to instantiate, loading file was enough
1245
+			// $instantiation_mode = "2) no constructor but instantiable";
1246
+			return $reflector->newInstance();
1247
+		}
1248
+		if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
1249
+			// $instantiation_mode = "3) new_instance_from_db()";
1250
+			return call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
1251
+		}
1252
+		if (method_exists($class_name, 'new_instance')) {
1253
+			// $instantiation_mode = "4) new_instance()";
1254
+			return call_user_func_array(array($class_name, 'new_instance'), $arguments);
1255
+		}
1256
+		if (method_exists($class_name, 'instance')) {
1257
+			// $instantiation_mode = "5) instance()";
1258
+			return call_user_func_array(array($class_name, 'instance'), $arguments);
1259
+		}
1260
+		if ($reflector->isInstantiable()) {
1261
+			// $instantiation_mode = "6) constructor";
1262
+			return $reflector->newInstanceArgs($arguments);
1263
+		}
1264
+		// heh ? something's not right !
1265
+		throw new EE_Error(
1266
+			sprintf(
1267
+				__('The %s file %s could not be instantiated.', 'event_espresso'),
1268
+				$type,
1269
+				$class_name
1270
+			)
1271
+		);
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
1277
+	 * @param array $array
1278
+	 * @return bool
1279
+	 */
1280
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
1281
+	{
1282
+		return ! empty($array)
1283
+			? array_keys($array) === range(0, count($array) - 1)
1284
+			: true;
1285
+	}
1286
+
1287
+
1288
+	/**
1289
+	 * _resolve_dependencies
1290
+	 * examines the constructor for the requested class to determine
1291
+	 * if any dependencies exist, and if they can be injected.
1292
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
1293
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
1294
+	 * For example:
1295
+	 *        if attempting to load a class "Foo" with the following constructor:
1296
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
1297
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
1298
+	 *        but only IF they are NOT already present in the incoming arguments array,
1299
+	 *        and the correct classes can be loaded
1300
+	 *
1301
+	 * @param ReflectionClass $reflector
1302
+	 * @param string          $class_name
1303
+	 * @param array           $arguments
1304
+	 * @return array
1305
+	 * @throws InvalidArgumentException
1306
+	 * @throws InvalidDataTypeException
1307
+	 * @throws InvalidInterfaceException
1308
+	 * @throws ReflectionException
1309
+	 */
1310
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, array $arguments = array())
1311
+	{
1312
+		// let's examine the constructor
1313
+		$constructor = $this->mirror->getConstructorFromReflection($reflector);
1314
+		// whu? huh? nothing?
1315
+		if (! $constructor) {
1316
+			return $arguments;
1317
+		}
1318
+		// get constructor parameters
1319
+		$params = $this->mirror->getParametersFromReflection($reflector);
1320
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1321
+		$argument_keys = array_keys($arguments);
1322
+		// now loop thru all of the constructors expected parameters
1323
+		foreach ($params as $index => $param) {
1324
+			// is this a dependency for a specific class ?
1325
+			$param_class = $this->mirror->getParameterClassName($param, $class_name, $index);
1326
+			// BUT WAIT !!! This class may be an alias for something else (or getting replaced at runtime)
1327
+			$param_class = $this->class_cache->isAlias($param_class, $class_name)
1328
+				? $this->class_cache->getFqnForAlias($param_class, $class_name)
1329
+				: $param_class;
1330
+			if (// param is not even a class
1331
+				$param_class === null
1332
+				// and something already exists in the incoming arguments for this param
1333
+				&& array_key_exists($index, $argument_keys)
1334
+				&& array_key_exists($argument_keys[ $index ], $arguments)
1335
+			) {
1336
+				// so let's skip this argument and move on to the next
1337
+				continue;
1338
+			}
1339
+			if (// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1340
+				$param_class !== null
1341
+				&& isset($argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ])
1342
+				&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
1343
+			) {
1344
+				// skip this argument and move on to the next
1345
+				continue;
1346
+			}
1347
+			if (// parameter is type hinted as a class, and should be injected
1348
+				$param_class !== null
1349
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1350
+			) {
1351
+				$arguments = $this->_resolve_dependency(
1352
+					$class_name,
1353
+					$param_class,
1354
+					$arguments,
1355
+					$index
1356
+				);
1357
+			} else {
1358
+				$arguments[ $index ] = $this->mirror->getParameterDefaultValue(
1359
+					$param,
1360
+					$class_name,
1361
+					$index
1362
+				);
1363
+			}
1364
+		}
1365
+		return $arguments;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * @param string $class_name
1371
+	 * @param string $param_class
1372
+	 * @param array  $arguments
1373
+	 * @param mixed  $index
1374
+	 * @return array
1375
+	 * @throws InvalidArgumentException
1376
+	 * @throws InvalidInterfaceException
1377
+	 * @throws InvalidDataTypeException
1378
+	 */
1379
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1380
+	{
1381
+		$dependency = null;
1382
+		// should dependency be loaded from cache ?
1383
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
1384
+			$class_name,
1385
+			$param_class
1386
+		);
1387
+		$cache_on = $cache_on !== EE_Dependency_Map::load_new_object;
1388
+		// we might have a dependency...
1389
+		// let's MAYBE try and find it in our cache if that's what's been requested
1390
+		$cached_class = $cache_on
1391
+			? $this->_get_cached_class($param_class)
1392
+			: null;
1393
+		// and grab it if it exists
1394
+		if ($cached_class instanceof $param_class) {
1395
+			$dependency = $cached_class;
1396
+		} elseif ($param_class !== $class_name) {
1397
+			// obtain the loader method from the dependency map
1398
+			$loader = $this->_dependency_map->class_loader($param_class);
1399
+			// is loader a custom closure ?
1400
+			if ($loader instanceof Closure) {
1401
+				$dependency = $loader($arguments);
1402
+			} else {
1403
+				// set the cache on property for the recursive loading call
1404
+				$this->_cache_on = $cache_on;
1405
+				// if not, then let's try and load it via the registry
1406
+				if ($loader && method_exists($this, $loader)) {
1407
+					$dependency = $this->{$loader}($param_class);
1408
+				} else {
1409
+					$dependency = LoaderFactory::getLoader()->load(
1410
+						$param_class,
1411
+						array(),
1412
+						$cache_on
1413
+					);
1414
+				}
1415
+			}
1416
+		}
1417
+		// did we successfully find the correct dependency ?
1418
+		if ($dependency instanceof $param_class) {
1419
+			// then let's inject it into the incoming array of arguments at the correct location
1420
+			$arguments[ $index ] = $dependency;
1421
+		}
1422
+		return $arguments;
1423
+	}
1424
+
1425
+
1426
+	/**
1427
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1428
+	 *
1429
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1430
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1431
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1432
+	 * @param array  $arguments
1433
+	 * @return object
1434
+	 */
1435
+	public static function factory($classname, $arguments = array())
1436
+	{
1437
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1438
+		if ($loader instanceof Closure) {
1439
+			return $loader($arguments);
1440
+		}
1441
+		if (method_exists(self::instance(), $loader)) {
1442
+			return self::instance()->{$loader}($classname, $arguments);
1443
+		}
1444
+		return null;
1445
+	}
1446
+
1447
+
1448
+	/**
1449
+	 * Gets the addon by its class name
1450
+	 *
1451
+	 * @param string $class_name
1452
+	 * @return EE_Addon
1453
+	 */
1454
+	public function getAddon($class_name)
1455
+	{
1456
+		$class_name = str_replace('\\', '_', $class_name);
1457
+		return $this->addons->{$class_name};
1458
+	}
1459
+
1460
+
1461
+	/**
1462
+	 * removes the addon from the internal cache
1463
+	 *
1464
+	 * @param string $class_name
1465
+	 * @return void
1466
+	 */
1467
+	public function removeAddon($class_name)
1468
+	{
1469
+		$class_name = str_replace('\\', '_', $class_name);
1470
+		unset($this->addons->{$class_name});
1471
+	}
1472
+
1473
+
1474
+	/**
1475
+	 * Gets the addon by its name/slug (not classname. For that, just
1476
+	 * use the get_addon() method above
1477
+	 *
1478
+	 * @param string $name
1479
+	 * @return EE_Addon
1480
+	 */
1481
+	public function get_addon_by_name($name)
1482
+	{
1483
+		foreach ($this->addons as $addon) {
1484
+			if ($addon->name() === $name) {
1485
+				return $addon;
1486
+			}
1487
+		}
1488
+		return null;
1489
+	}
1490
+
1491
+
1492
+	/**
1493
+	 * Gets an array of all the registered addons, where the keys are their names.
1494
+	 * (ie, what each returns for their name() function)
1495
+	 * They're already available on EE_Registry::instance()->addons as properties,
1496
+	 * where each property's name is the addon's classname,
1497
+	 * So if you just want to get the addon by classname,
1498
+	 * OR use the get_addon() method above.
1499
+	 * PLEASE  NOTE:
1500
+	 * addons with Fully Qualified Class Names
1501
+	 * have had the namespace separators converted to underscores,
1502
+	 * so a classname like Fully\Qualified\ClassName
1503
+	 * would have been converted to Fully_Qualified_ClassName
1504
+	 *
1505
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1506
+	 */
1507
+	public function get_addons_by_name()
1508
+	{
1509
+		$addons = array();
1510
+		foreach ($this->addons as $addon) {
1511
+			$addons[ $addon->name() ] = $addon;
1512
+		}
1513
+		return $addons;
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1519
+	 * a stale copy of it around
1520
+	 *
1521
+	 * @param string $model_name
1522
+	 * @return \EEM_Base
1523
+	 * @throws \EE_Error
1524
+	 */
1525
+	public function reset_model($model_name)
1526
+	{
1527
+		$model_class_name = strpos($model_name, 'EEM_') !== 0
1528
+			? "EEM_{$model_name}"
1529
+			: $model_name;
1530
+		if (! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1531
+			return null;
1532
+		}
1533
+		// get that model reset it and make sure we nuke the old reference to it
1534
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name
1535
+			&& is_callable(
1536
+				array($model_class_name, 'reset')
1537
+			)) {
1538
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1539
+		} else {
1540
+			throw new EE_Error(
1541
+				sprintf(
1542
+					esc_html__('Model %s does not have a method "reset"', 'event_espresso'),
1543
+					$model_name
1544
+				)
1545
+			);
1546
+		}
1547
+		return $this->LIB->{$model_class_name};
1548
+	}
1549
+
1550
+
1551
+	/**
1552
+	 * Resets the registry.
1553
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when
1554
+	 * switch_to_blog is used in a multisite install.  Here is a list of things that are NOT reset.
1555
+	 * - $_dependency_map
1556
+	 * - $_class_abbreviations
1557
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1558
+	 * - $REQ:  Still on the same request so no need to change.
1559
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1560
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only
1561
+	 * one Session can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1562
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1563
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1564
+	 *             switch or on the restore.
1565
+	 * - $modules
1566
+	 * - $shortcodes
1567
+	 * - $widgets
1568
+	 *
1569
+	 * @param boolean $hard             [deprecated]
1570
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1571
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not
1572
+	 *                                  sure if you CAN currently reinstantiate the singletons at the moment)
1573
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so
1574
+	 *                                  client
1575
+	 *                                  code instead can just change the model context to a different blog id if
1576
+	 *                                  necessary
1577
+	 * @return EE_Registry
1578
+	 * @throws InvalidInterfaceException
1579
+	 * @throws InvalidDataTypeException
1580
+	 * @throws EE_Error
1581
+	 * @throws ReflectionException
1582
+	 * @throws InvalidArgumentException
1583
+	 */
1584
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1585
+	{
1586
+		$instance = self::instance();
1587
+		$instance->_cache_on = true;
1588
+		// reset some "special" classes
1589
+		EEH_Activation::reset();
1590
+		$hard = apply_filters('FHEE__EE_Registry__reset__hard', $hard);
1591
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1592
+		$instance->CART = null;
1593
+		$instance->MRM = null;
1594
+		$instance->AssetsRegistry = LoaderFactory::getLoader()->getShared(
1595
+			'EventEspresso\core\services\assets\Registry'
1596
+		);
1597
+		// messages reset
1598
+		EED_Messages::reset();
1599
+		// handle of objects cached on LIB
1600
+		foreach (array('LIB', 'modules') as $cache) {
1601
+			foreach ($instance->{$cache} as $class_name => $class) {
1602
+				if (self::_reset_and_unset_object($class, $reset_models)) {
1603
+					unset($instance->{$cache}->{$class_name});
1604
+				}
1605
+			}
1606
+		}
1607
+		return $instance;
1608
+	}
1609
+
1610
+
1611
+	/**
1612
+	 * if passed object implements ResettableInterface, then call it's reset() method
1613
+	 * if passed object implements InterminableInterface, then return false,
1614
+	 * to indicate that it should NOT be cleared from the Registry cache
1615
+	 *
1616
+	 * @param      $object
1617
+	 * @param bool $reset_models
1618
+	 * @return bool returns true if cached object should be unset
1619
+	 */
1620
+	private static function _reset_and_unset_object($object, $reset_models)
1621
+	{
1622
+		if (! is_object($object)) {
1623
+			// don't unset anything that's not an object
1624
+			return false;
1625
+		}
1626
+		if ($object instanceof EED_Module) {
1627
+			$object::reset();
1628
+			// don't unset modules
1629
+			return false;
1630
+		}
1631
+		if ($object instanceof ResettableInterface) {
1632
+			if ($object instanceof EEM_Base) {
1633
+				if ($reset_models) {
1634
+					$object->reset();
1635
+					return true;
1636
+				}
1637
+				return false;
1638
+			}
1639
+			$object->reset();
1640
+			return true;
1641
+		}
1642
+		if (! $object instanceof InterminableInterface) {
1643
+			return true;
1644
+		}
1645
+		return false;
1646
+	}
1647
+
1648
+
1649
+	/**
1650
+	 * Gets all the custom post type models defined
1651
+	 *
1652
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1653
+	 */
1654
+	public function cpt_models()
1655
+	{
1656
+		$cpt_models = array();
1657
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1658
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1659
+				$cpt_models[ $short_name ] = $classname;
1660
+			}
1661
+		}
1662
+		return $cpt_models;
1663
+	}
1664
+
1665
+
1666
+	/**
1667
+	 * @return \EE_Config
1668
+	 */
1669
+	public static function CFG()
1670
+	{
1671
+		return self::instance()->CFG;
1672
+	}
1673
+
1674
+
1675
+	/**
1676
+	 * @deprecated 4.9.62.p
1677
+	 * @param string $class_name
1678
+	 * @return ReflectionClass
1679
+	 * @throws ReflectionException
1680
+	 * @throws InvalidDataTypeException
1681
+	 */
1682
+	public function get_ReflectionClass($class_name)
1683
+	{
1684
+		return $this->mirror->getReflectionClass($class_name);
1685
+	}
1686 1686
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 1 patch
Indentation   +550 added lines, -550 removed lines patch added patch discarded remove patch
@@ -23,561 +23,561 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
-
28
-    /**
29
-     * @var AssetCollection $assets
30
-     */
31
-    protected $assets;
32
-
33
-    /**
34
-     * @var I18nRegistry
35
-     */
36
-    private $i18n_registry;
37
-
38
-    /**
39
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $jsdata = array();
44
-
45
-    /**
46
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
-     * page source.
48
-     *
49
-     * @var array
50
-     */
51
-    private $script_handles_with_data = array();
52
-
53
-
54
-    /**
55
-     * Holds the manifest data obtained from registered manifest files.
56
-     * Manifests are maps of asset chunk name to actual built asset file names.
57
-     * Shape of this array is:
58
-     * array(
59
-     *  'some_namespace_slug' => array(
60
-     *      'some_chunk_name' => array(
61
-     *          'js' => 'filename.js'
62
-     *          'css' => 'filename.js'
63
-     *      ),
64
-     *      'url_base' => 'https://baseurl.com/to/assets
65
-     *  )
66
-     * )
67
-     *
68
-     * @var array
69
-     */
70
-    private $manifest_data = array();
71
-
72
-
73
-    /**
74
-     * Registry constructor.
75
-     * Hooking into WP actions for script registry.
76
-     *
77
-     * @param AssetCollection $assets
78
-     * @param I18nRegistry    $i18n_registry
79
-     */
80
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
81
-    {
82
-        $this->assets = $assets;
83
-        $this->i18n_registry = $i18n_registry;
84
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
86
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
88
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
89
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
90
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
91
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
92
-    }
93
-
94
-
95
-    /**
96
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
97
-     * translation handling.
98
-     *
99
-     * @return I18nRegistry
100
-     */
101
-    public function getI18nRegistry()
102
-    {
103
-        return $this->i18n_registry;
104
-    }
105
-
106
-
107
-    /**
108
-     * Callback for the wp_enqueue_scripts actions used to register assets.
109
-     *
110
-     * @since 4.9.62.p
111
-     * @throws Exception
112
-     */
113
-    public function registerScriptsAndStyles()
114
-    {
115
-        try {
116
-            $this->registerScripts($this->assets->getJavascriptAssets());
117
-            $this->registerStyles($this->assets->getStylesheetAssets());
118
-        } catch (Exception $exception) {
119
-            new ExceptionStackTraceDisplay($exception);
120
-        }
121
-    }
122
-
123
-
124
-    /**
125
-     * Registers JS assets with WP core
126
-     *
127
-     * @since 4.9.62.p
128
-     * @param JavascriptAsset[] $scripts
129
-     * @throws AssetRegistrationException
130
-     * @throws InvalidDataTypeException
131
-     */
132
-    public function registerScripts(array $scripts)
133
-    {
134
-        foreach ($scripts as $script) {
135
-            // skip to next script if this has already been done
136
-            if ($script->isRegistered()) {
137
-                continue;
138
-            }
139
-            do_action(
140
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
141
-                $script
142
-            );
143
-            $registered = wp_register_script(
144
-                $script->handle(),
145
-                $script->source(),
146
-                $script->dependencies(),
147
-                $script->version(),
148
-                $script->loadInFooter()
149
-            );
150
-            if (defined('EE_DEBUG') && EE_DEBUG && ! $registered) {
151
-                throw new AssetRegistrationException($script->handle());
152
-            }
153
-            $script->setRegistered($registered);
154
-            if ($script->requiresTranslation()) {
155
-                $this->registerTranslation($script->handle());
156
-            }
157
-            do_action(
158
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
159
-                $script
160
-            );
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * Registers CSS assets with WP core
167
-     *
168
-     * @since 4.9.62.p
169
-     * @param StylesheetAsset[] $styles
170
-     * @throws InvalidDataTypeException
171
-     */
172
-    public function registerStyles(array $styles)
173
-    {
174
-        foreach ($styles as $style) {
175
-            // skip to next style if this has already been done
176
-            if ($style->isRegistered()) {
177
-                continue;
178
-            }
179
-            do_action(
180
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
181
-                $style
182
-            );
183
-            wp_enqueue_style(
184
-                $style->handle(),
185
-                $style->source(),
186
-                $style->dependencies(),
187
-                $style->version(),
188
-                $style->media()
189
-            );
190
-            $style->setRegistered();
191
-            do_action(
192
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
193
-                $style
194
-            );
195
-        }
196
-    }
197
-
198
-
199
-    /**
200
-     * Call back for the script print in frontend and backend.
201
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
202
-     *
203
-     * @since 4.9.31.rc.015
204
-     */
205
-    public function enqueueData()
206
-    {
207
-        $this->removeAlreadyRegisteredDataForScriptHandles();
208
-        wp_add_inline_script(
209
-            'eejs-core',
210
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
211
-            'before'
212
-        );
213
-        $scripts = $this->assets->getJavascriptAssetsWithData();
214
-        foreach ($scripts as $script) {
215
-            $this->addRegisteredScriptHandlesWithData($script->handle());
216
-            if ($script->hasLocalizationCallback()) {
217
-                $localize = $script->localizationCallback();
218
-                $localize();
219
-            }
220
-        }
221
-    }
222
-
223
-
224
-    /**
225
-     * Used to add data to eejs.data object.
226
-     * Note:  Overriding existing data is not allowed.
227
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
228
-     * If the data you add is something like this:
229
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
230
-     * It will be exposed in the page source as:
231
-     *  eejs.data.my_plugin_data.foo == gar
232
-     *
233
-     * @param string       $key   Key used to access your data
234
-     * @param string|array $value Value to attach to key
235
-     * @throws InvalidArgumentException
236
-     */
237
-    public function addData($key, $value)
238
-    {
239
-        if ($this->verifyDataNotExisting($key)) {
240
-            $this->jsdata[ $key ] = $value;
241
-        }
242
-    }
243
-
244
-
245
-    /**
246
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
247
-     * elements in an array.
248
-     * When you use this method, the value you include will be appended to the end of an array on $key.
249
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
250
-     * object like this, eejs.data.test = [ my_data,
251
-     * ]
252
-     * If there has already been a scalar value attached to the data object given key, then
253
-     * this will throw an exception.
254
-     *
255
-     * @param string       $key   Key to attach data to.
256
-     * @param string|array $value Value being registered.
257
-     * @throws InvalidArgumentException
258
-     */
259
-    public function pushData($key, $value)
260
-    {
261
-        if (isset($this->jsdata[ $key ])
262
-            && ! is_array($this->jsdata[ $key ])
263
-        ) {
264
-            throw new InvalidArgumentException(
265
-                sprintf(
266
-                    __(
267
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
+
28
+	/**
29
+	 * @var AssetCollection $assets
30
+	 */
31
+	protected $assets;
32
+
33
+	/**
34
+	 * @var I18nRegistry
35
+	 */
36
+	private $i18n_registry;
37
+
38
+	/**
39
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $jsdata = array();
44
+
45
+	/**
46
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
+	 * page source.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	private $script_handles_with_data = array();
52
+
53
+
54
+	/**
55
+	 * Holds the manifest data obtained from registered manifest files.
56
+	 * Manifests are maps of asset chunk name to actual built asset file names.
57
+	 * Shape of this array is:
58
+	 * array(
59
+	 *  'some_namespace_slug' => array(
60
+	 *      'some_chunk_name' => array(
61
+	 *          'js' => 'filename.js'
62
+	 *          'css' => 'filename.js'
63
+	 *      ),
64
+	 *      'url_base' => 'https://baseurl.com/to/assets
65
+	 *  )
66
+	 * )
67
+	 *
68
+	 * @var array
69
+	 */
70
+	private $manifest_data = array();
71
+
72
+
73
+	/**
74
+	 * Registry constructor.
75
+	 * Hooking into WP actions for script registry.
76
+	 *
77
+	 * @param AssetCollection $assets
78
+	 * @param I18nRegistry    $i18n_registry
79
+	 */
80
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
81
+	{
82
+		$this->assets = $assets;
83
+		$this->i18n_registry = $i18n_registry;
84
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
86
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
88
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
89
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
90
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
91
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
92
+	}
93
+
94
+
95
+	/**
96
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
97
+	 * translation handling.
98
+	 *
99
+	 * @return I18nRegistry
100
+	 */
101
+	public function getI18nRegistry()
102
+	{
103
+		return $this->i18n_registry;
104
+	}
105
+
106
+
107
+	/**
108
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
109
+	 *
110
+	 * @since 4.9.62.p
111
+	 * @throws Exception
112
+	 */
113
+	public function registerScriptsAndStyles()
114
+	{
115
+		try {
116
+			$this->registerScripts($this->assets->getJavascriptAssets());
117
+			$this->registerStyles($this->assets->getStylesheetAssets());
118
+		} catch (Exception $exception) {
119
+			new ExceptionStackTraceDisplay($exception);
120
+		}
121
+	}
122
+
123
+
124
+	/**
125
+	 * Registers JS assets with WP core
126
+	 *
127
+	 * @since 4.9.62.p
128
+	 * @param JavascriptAsset[] $scripts
129
+	 * @throws AssetRegistrationException
130
+	 * @throws InvalidDataTypeException
131
+	 */
132
+	public function registerScripts(array $scripts)
133
+	{
134
+		foreach ($scripts as $script) {
135
+			// skip to next script if this has already been done
136
+			if ($script->isRegistered()) {
137
+				continue;
138
+			}
139
+			do_action(
140
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
141
+				$script
142
+			);
143
+			$registered = wp_register_script(
144
+				$script->handle(),
145
+				$script->source(),
146
+				$script->dependencies(),
147
+				$script->version(),
148
+				$script->loadInFooter()
149
+			);
150
+			if (defined('EE_DEBUG') && EE_DEBUG && ! $registered) {
151
+				throw new AssetRegistrationException($script->handle());
152
+			}
153
+			$script->setRegistered($registered);
154
+			if ($script->requiresTranslation()) {
155
+				$this->registerTranslation($script->handle());
156
+			}
157
+			do_action(
158
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
159
+				$script
160
+			);
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * Registers CSS assets with WP core
167
+	 *
168
+	 * @since 4.9.62.p
169
+	 * @param StylesheetAsset[] $styles
170
+	 * @throws InvalidDataTypeException
171
+	 */
172
+	public function registerStyles(array $styles)
173
+	{
174
+		foreach ($styles as $style) {
175
+			// skip to next style if this has already been done
176
+			if ($style->isRegistered()) {
177
+				continue;
178
+			}
179
+			do_action(
180
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
181
+				$style
182
+			);
183
+			wp_enqueue_style(
184
+				$style->handle(),
185
+				$style->source(),
186
+				$style->dependencies(),
187
+				$style->version(),
188
+				$style->media()
189
+			);
190
+			$style->setRegistered();
191
+			do_action(
192
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
193
+				$style
194
+			);
195
+		}
196
+	}
197
+
198
+
199
+	/**
200
+	 * Call back for the script print in frontend and backend.
201
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
202
+	 *
203
+	 * @since 4.9.31.rc.015
204
+	 */
205
+	public function enqueueData()
206
+	{
207
+		$this->removeAlreadyRegisteredDataForScriptHandles();
208
+		wp_add_inline_script(
209
+			'eejs-core',
210
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
211
+			'before'
212
+		);
213
+		$scripts = $this->assets->getJavascriptAssetsWithData();
214
+		foreach ($scripts as $script) {
215
+			$this->addRegisteredScriptHandlesWithData($script->handle());
216
+			if ($script->hasLocalizationCallback()) {
217
+				$localize = $script->localizationCallback();
218
+				$localize();
219
+			}
220
+		}
221
+	}
222
+
223
+
224
+	/**
225
+	 * Used to add data to eejs.data object.
226
+	 * Note:  Overriding existing data is not allowed.
227
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
228
+	 * If the data you add is something like this:
229
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
230
+	 * It will be exposed in the page source as:
231
+	 *  eejs.data.my_plugin_data.foo == gar
232
+	 *
233
+	 * @param string       $key   Key used to access your data
234
+	 * @param string|array $value Value to attach to key
235
+	 * @throws InvalidArgumentException
236
+	 */
237
+	public function addData($key, $value)
238
+	{
239
+		if ($this->verifyDataNotExisting($key)) {
240
+			$this->jsdata[ $key ] = $value;
241
+		}
242
+	}
243
+
244
+
245
+	/**
246
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
247
+	 * elements in an array.
248
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
249
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
250
+	 * object like this, eejs.data.test = [ my_data,
251
+	 * ]
252
+	 * If there has already been a scalar value attached to the data object given key, then
253
+	 * this will throw an exception.
254
+	 *
255
+	 * @param string       $key   Key to attach data to.
256
+	 * @param string|array $value Value being registered.
257
+	 * @throws InvalidArgumentException
258
+	 */
259
+	public function pushData($key, $value)
260
+	{
261
+		if (isset($this->jsdata[ $key ])
262
+			&& ! is_array($this->jsdata[ $key ])
263
+		) {
264
+			throw new InvalidArgumentException(
265
+				sprintf(
266
+					__(
267
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
268 268
                          push values to this data element when it is an array.',
269
-                        'event_espresso'
270
-                    ),
271
-                    $key,
272
-                    __METHOD__
273
-                )
274
-            );
275
-        }
276
-        $this->jsdata[ $key ][] = $value;
277
-    }
278
-
279
-
280
-    /**
281
-     * Used to set content used by javascript for a template.
282
-     * Note: Overrides of existing registered templates are not allowed.
283
-     *
284
-     * @param string $template_reference
285
-     * @param string $template_content
286
-     * @throws InvalidArgumentException
287
-     */
288
-    public function addTemplate($template_reference, $template_content)
289
-    {
290
-        if (! isset($this->jsdata['templates'])) {
291
-            $this->jsdata['templates'] = array();
292
-        }
293
-        //no overrides allowed.
294
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
295
-            throw new InvalidArgumentException(
296
-                sprintf(
297
-                    __(
298
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
299
-                        'event_espresso'
300
-                    ),
301
-                    $template_reference
302
-                )
303
-            );
304
-        }
305
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
306
-    }
307
-
308
-
309
-    /**
310
-     * Retrieve the template content already registered for the given reference.
311
-     *
312
-     * @param string $template_reference
313
-     * @return string
314
-     */
315
-    public function getTemplate($template_reference)
316
-    {
317
-        return isset($this->jsdata['templates'][ $template_reference ])
318
-            ? $this->jsdata['templates'][ $template_reference ]
319
-            : '';
320
-    }
321
-
322
-
323
-    /**
324
-     * Retrieve registered data.
325
-     *
326
-     * @param string $key Name of key to attach data to.
327
-     * @return mixed                If there is no for the given key, then false is returned.
328
-     */
329
-    public function getData($key)
330
-    {
331
-        return isset($this->jsdata[ $key ])
332
-            ? $this->jsdata[ $key ]
333
-            : false;
334
-    }
335
-
336
-
337
-    /**
338
-     * Verifies whether the given data exists already on the jsdata array.
339
-     * Overriding data is not allowed.
340
-     *
341
-     * @param string $key Index for data.
342
-     * @return bool        If valid then return true.
343
-     * @throws InvalidArgumentException if data already exists.
344
-     */
345
-    protected function verifyDataNotExisting($key)
346
-    {
347
-        if (isset($this->jsdata[ $key ])) {
348
-            if (is_array($this->jsdata[ $key ])) {
349
-                throw new InvalidArgumentException(
350
-                    sprintf(
351
-                        __(
352
-                            'The value for %1$s already exists in the Registry::eejs object.
269
+						'event_espresso'
270
+					),
271
+					$key,
272
+					__METHOD__
273
+				)
274
+			);
275
+		}
276
+		$this->jsdata[ $key ][] = $value;
277
+	}
278
+
279
+
280
+	/**
281
+	 * Used to set content used by javascript for a template.
282
+	 * Note: Overrides of existing registered templates are not allowed.
283
+	 *
284
+	 * @param string $template_reference
285
+	 * @param string $template_content
286
+	 * @throws InvalidArgumentException
287
+	 */
288
+	public function addTemplate($template_reference, $template_content)
289
+	{
290
+		if (! isset($this->jsdata['templates'])) {
291
+			$this->jsdata['templates'] = array();
292
+		}
293
+		//no overrides allowed.
294
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
295
+			throw new InvalidArgumentException(
296
+				sprintf(
297
+					__(
298
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
299
+						'event_espresso'
300
+					),
301
+					$template_reference
302
+				)
303
+			);
304
+		}
305
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
306
+	}
307
+
308
+
309
+	/**
310
+	 * Retrieve the template content already registered for the given reference.
311
+	 *
312
+	 * @param string $template_reference
313
+	 * @return string
314
+	 */
315
+	public function getTemplate($template_reference)
316
+	{
317
+		return isset($this->jsdata['templates'][ $template_reference ])
318
+			? $this->jsdata['templates'][ $template_reference ]
319
+			: '';
320
+	}
321
+
322
+
323
+	/**
324
+	 * Retrieve registered data.
325
+	 *
326
+	 * @param string $key Name of key to attach data to.
327
+	 * @return mixed                If there is no for the given key, then false is returned.
328
+	 */
329
+	public function getData($key)
330
+	{
331
+		return isset($this->jsdata[ $key ])
332
+			? $this->jsdata[ $key ]
333
+			: false;
334
+	}
335
+
336
+
337
+	/**
338
+	 * Verifies whether the given data exists already on the jsdata array.
339
+	 * Overriding data is not allowed.
340
+	 *
341
+	 * @param string $key Index for data.
342
+	 * @return bool        If valid then return true.
343
+	 * @throws InvalidArgumentException if data already exists.
344
+	 */
345
+	protected function verifyDataNotExisting($key)
346
+	{
347
+		if (isset($this->jsdata[ $key ])) {
348
+			if (is_array($this->jsdata[ $key ])) {
349
+				throw new InvalidArgumentException(
350
+					sprintf(
351
+						__(
352
+							'The value for %1$s already exists in the Registry::eejs object.
353 353
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
354 354
                             %2$s method to push your value to the array.',
355
-                            'event_espresso'
356
-                        ),
357
-                        $key,
358
-                        'pushData()'
359
-                    )
360
-                );
361
-            }
362
-            throw new InvalidArgumentException(
363
-                sprintf(
364
-                    __(
365
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
355
+							'event_espresso'
356
+						),
357
+						$key,
358
+						'pushData()'
359
+					)
360
+				);
361
+			}
362
+			throw new InvalidArgumentException(
363
+				sprintf(
364
+					__(
365
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
366 366
                         allowed.  Consider attaching your value to a different key',
367
-                        'event_espresso'
368
-                    ),
369
-                    $key
370
-                )
371
-            );
372
-        }
373
-        return true;
374
-    }
375
-
376
-
377
-    /**
378
-     * Get the actual asset path for asset manifests.
379
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
380
-     *
381
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
382
-     *                           asset file location.
383
-     * @param string $chunk_name
384
-     * @param string $asset_type
385
-     * @return string
386
-     * @since 4.9.59.p
387
-     */
388
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
389
-    {
390
-        $url = isset(
391
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
392
-            $this->manifest_data[ $namespace ]['url_base']
393
-        )
394
-            ? $this->manifest_data[ $namespace ]['url_base']
395
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
396
-            : $chunk_name;
397
-        return apply_filters(
398
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
399
-            $url,
400
-            $namespace,
401
-            $chunk_name,
402
-            $asset_type
403
-        );
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * Return the url to a js file for the given namespace and chunk name.
410
-     *
411
-     * @param string $namespace
412
-     * @param string $chunk_name
413
-     * @return string
414
-     */
415
-    public function getJsUrl($namespace, $chunk_name)
416
-    {
417
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
418
-    }
419
-
420
-
421
-    /**
422
-     * Return the url to a css file for the given namespace and chunk name.
423
-     *
424
-     * @param string $namespace
425
-     * @param string $chunk_name
426
-     * @return string
427
-     */
428
-    public function getCssUrl($namespace, $chunk_name)
429
-    {
430
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
431
-    }
432
-
433
-
434
-    /**
435
-     * @since 4.9.62.p
436
-     * @throws InvalidArgumentException
437
-     * @throws InvalidFilePathException
438
-     */
439
-    public function registerManifestFiles()
440
-    {
441
-        $manifest_files = $this->assets->getManifestFiles();
442
-        foreach ($manifest_files as $manifest_file) {
443
-            $this->registerManifestFile(
444
-                $manifest_file->assetNamespace(),
445
-                $manifest_file->urlBase(),
446
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
447
-            );
448
-        }
449
-    }
450
-
451
-
452
-    /**
453
-     * Used to register a js/css manifest file with the registered_manifest_files property.
454
-     *
455
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
456
-     * @param string $url_base      The url base for the manifest file location.
457
-     * @param string $manifest_file The absolute path to the manifest file.
458
-     * @throws InvalidArgumentException
459
-     * @throws InvalidFilePathException
460
-     * @since 4.9.59.p
461
-     */
462
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
463
-    {
464
-        if (isset($this->manifest_data[ $namespace ])) {
465
-            throw new InvalidArgumentException(
466
-                sprintf(
467
-                    esc_html__(
468
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
469
-                        'event_espresso'
470
-                    ),
471
-                    $namespace
472
-                )
473
-            );
474
-        }
475
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
476
-            if (is_admin()) {
477
-                EE_Error::add_error(
478
-                    sprintf(
479
-                        esc_html__(
480
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
481
-                            'event_espresso'
482
-                        ),
483
-                        'Event Espresso',
484
-                        $url_base,
485
-                        'plugins_url',
486
-                        'WP_PLUGIN_URL'
487
-                    ),
488
-                    __FILE__,
489
-                    __FUNCTION__,
490
-                    __LINE__
491
-                );
492
-            }
493
-            return;
494
-        }
495
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
496
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
497
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
498
-        }
499
-    }
500
-
501
-
502
-    /**
503
-     * Decodes json from the provided manifest file.
504
-     *
505
-     * @since 4.9.59.p
506
-     * @param string $manifest_file Path to manifest file.
507
-     * @return array
508
-     * @throws InvalidFilePathException
509
-     */
510
-    private function decodeManifestFile($manifest_file)
511
-    {
512
-        if (! file_exists($manifest_file)) {
513
-            throw new InvalidFilePathException($manifest_file);
514
-        }
515
-        return json_decode(file_get_contents($manifest_file), true);
516
-    }
517
-
518
-
519
-    /**
520
-     * This is used to set registered script handles that have data.
521
-     *
522
-     * @param string $script_handle
523
-     */
524
-    private function addRegisteredScriptHandlesWithData($script_handle)
525
-    {
526
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
527
-    }
528
-
529
-
530
-    /**i
367
+						'event_espresso'
368
+					),
369
+					$key
370
+				)
371
+			);
372
+		}
373
+		return true;
374
+	}
375
+
376
+
377
+	/**
378
+	 * Get the actual asset path for asset manifests.
379
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
380
+	 *
381
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
382
+	 *                           asset file location.
383
+	 * @param string $chunk_name
384
+	 * @param string $asset_type
385
+	 * @return string
386
+	 * @since 4.9.59.p
387
+	 */
388
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
389
+	{
390
+		$url = isset(
391
+			$this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
392
+			$this->manifest_data[ $namespace ]['url_base']
393
+		)
394
+			? $this->manifest_data[ $namespace ]['url_base']
395
+			  . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
396
+			: $chunk_name;
397
+		return apply_filters(
398
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
399
+			$url,
400
+			$namespace,
401
+			$chunk_name,
402
+			$asset_type
403
+		);
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * Return the url to a js file for the given namespace and chunk name.
410
+	 *
411
+	 * @param string $namespace
412
+	 * @param string $chunk_name
413
+	 * @return string
414
+	 */
415
+	public function getJsUrl($namespace, $chunk_name)
416
+	{
417
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
418
+	}
419
+
420
+
421
+	/**
422
+	 * Return the url to a css file for the given namespace and chunk name.
423
+	 *
424
+	 * @param string $namespace
425
+	 * @param string $chunk_name
426
+	 * @return string
427
+	 */
428
+	public function getCssUrl($namespace, $chunk_name)
429
+	{
430
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
431
+	}
432
+
433
+
434
+	/**
435
+	 * @since 4.9.62.p
436
+	 * @throws InvalidArgumentException
437
+	 * @throws InvalidFilePathException
438
+	 */
439
+	public function registerManifestFiles()
440
+	{
441
+		$manifest_files = $this->assets->getManifestFiles();
442
+		foreach ($manifest_files as $manifest_file) {
443
+			$this->registerManifestFile(
444
+				$manifest_file->assetNamespace(),
445
+				$manifest_file->urlBase(),
446
+				$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
447
+			);
448
+		}
449
+	}
450
+
451
+
452
+	/**
453
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
454
+	 *
455
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
456
+	 * @param string $url_base      The url base for the manifest file location.
457
+	 * @param string $manifest_file The absolute path to the manifest file.
458
+	 * @throws InvalidArgumentException
459
+	 * @throws InvalidFilePathException
460
+	 * @since 4.9.59.p
461
+	 */
462
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
463
+	{
464
+		if (isset($this->manifest_data[ $namespace ])) {
465
+			throw new InvalidArgumentException(
466
+				sprintf(
467
+					esc_html__(
468
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
469
+						'event_espresso'
470
+					),
471
+					$namespace
472
+				)
473
+			);
474
+		}
475
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
476
+			if (is_admin()) {
477
+				EE_Error::add_error(
478
+					sprintf(
479
+						esc_html__(
480
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
481
+							'event_espresso'
482
+						),
483
+						'Event Espresso',
484
+						$url_base,
485
+						'plugins_url',
486
+						'WP_PLUGIN_URL'
487
+					),
488
+					__FILE__,
489
+					__FUNCTION__,
490
+					__LINE__
491
+				);
492
+			}
493
+			return;
494
+		}
495
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
496
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
497
+			$this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
498
+		}
499
+	}
500
+
501
+
502
+	/**
503
+	 * Decodes json from the provided manifest file.
504
+	 *
505
+	 * @since 4.9.59.p
506
+	 * @param string $manifest_file Path to manifest file.
507
+	 * @return array
508
+	 * @throws InvalidFilePathException
509
+	 */
510
+	private function decodeManifestFile($manifest_file)
511
+	{
512
+		if (! file_exists($manifest_file)) {
513
+			throw new InvalidFilePathException($manifest_file);
514
+		}
515
+		return json_decode(file_get_contents($manifest_file), true);
516
+	}
517
+
518
+
519
+	/**
520
+	 * This is used to set registered script handles that have data.
521
+	 *
522
+	 * @param string $script_handle
523
+	 */
524
+	private function addRegisteredScriptHandlesWithData($script_handle)
525
+	{
526
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
527
+	}
528
+
529
+
530
+	/**i
531 531
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
532 532
      * Dependency stored in WP_Scripts if its set.
533 533
      */
534
-    private function removeAlreadyRegisteredDataForScriptHandles()
535
-    {
536
-        if (empty($this->script_handles_with_data)) {
537
-            return;
538
-        }
539
-        foreach ($this->script_handles_with_data as $script_handle) {
540
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
541
-        }
542
-    }
543
-
544
-
545
-    /**
546
-     * Removes any data dependency registered in WP_Scripts if its set.
547
-     *
548
-     * @param string $script_handle
549
-     */
550
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
551
-    {
552
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
553
-            global $wp_scripts;
554
-            $unset_handle = false;
555
-            if ($wp_scripts->get_data($script_handle, 'data')) {
556
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
557
-                $unset_handle = true;
558
-            }
559
-            //deal with inline_scripts
560
-            if ($wp_scripts->get_data($script_handle, 'before')) {
561
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
562
-                $unset_handle = true;
563
-            }
564
-            if ($wp_scripts->get_data($script_handle, 'after')) {
565
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
566
-            }
567
-            if ($unset_handle) {
568
-                unset($this->script_handles_with_data[ $script_handle ]);
569
-            }
570
-        }
571
-    }
572
-
573
-
574
-    /**
575
-     * register translations for a registered script
576
-     *
577
-     * @param string $handle
578
-     */
579
-    public function registerTranslation($handle)
580
-    {
581
-        $this->i18n_registry->registerScriptI18n($handle);
582
-    }
534
+	private function removeAlreadyRegisteredDataForScriptHandles()
535
+	{
536
+		if (empty($this->script_handles_with_data)) {
537
+			return;
538
+		}
539
+		foreach ($this->script_handles_with_data as $script_handle) {
540
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
541
+		}
542
+	}
543
+
544
+
545
+	/**
546
+	 * Removes any data dependency registered in WP_Scripts if its set.
547
+	 *
548
+	 * @param string $script_handle
549
+	 */
550
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
551
+	{
552
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
553
+			global $wp_scripts;
554
+			$unset_handle = false;
555
+			if ($wp_scripts->get_data($script_handle, 'data')) {
556
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
557
+				$unset_handle = true;
558
+			}
559
+			//deal with inline_scripts
560
+			if ($wp_scripts->get_data($script_handle, 'before')) {
561
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
562
+				$unset_handle = true;
563
+			}
564
+			if ($wp_scripts->get_data($script_handle, 'after')) {
565
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
566
+			}
567
+			if ($unset_handle) {
568
+				unset($this->script_handles_with_data[ $script_handle ]);
569
+			}
570
+		}
571
+	}
572
+
573
+
574
+	/**
575
+	 * register translations for a registered script
576
+	 *
577
+	 * @param string $handle
578
+	 */
579
+	public function registerTranslation($handle)
580
+	{
581
+		$this->i18n_registry->registerScriptI18n($handle);
582
+	}
583 583
 }
Please login to merge, or discard this patch.
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +332 added lines, -332 removed lines patch added patch discarded remove patch
@@ -28,336 +28,336 @@
 block discarded – undo
28 28
 class CoreAssetManager extends AssetManager
29 29
 {
30 30
 
31
-    // WordPress core / Third party JS asset handles
32
-    const JS_HANDLE_JQUERY                = 'jquery';
33
-
34
-    const JS_HANDLE_JQUERY_VALIDATE       = 'jquery-validate';
35
-
36
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
37
-
38
-    const JS_HANDLE_UNDERSCORE            = 'underscore';
39
-
40
-    const JS_HANDLE_ACCOUNTING_CORE       = 'ee-accounting-core';
41
-
42
-    // EE JS assets handles
43
-    const JS_HANDLE_EE_MANIFEST        = 'ee-manifest';
44
-
45
-    const JS_HANDLE_EE_JS_CORE         = 'eejs-core';
46
-
47
-    const JS_HANDLE_EE_VENDOR_REACT    = 'ee-vendor-react';
48
-
49
-    const JS_HANDLE_EE_JS_API          = 'eejs-api';
50
-
51
-    const JS_HANDLE_EE_CORE            = 'espresso_core';
52
-
53
-    const JS_HANDLE_EE_I18N            = 'eei18n';
54
-
55
-    const JS_HANDLE_EE_ACCOUNTING      = 'ee-accounting';
56
-
57
-    const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
58
-
59
-    // EE CSS assets handles
60
-    const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
61
-
62
-    const CSS_HANDLE_EE_CUSTOM  = 'espresso_custom_css';
63
-
64
-    /**
65
-     * @var EE_Currency_Config $currency_config
66
-     */
67
-    protected $currency_config;
68
-
69
-    /**
70
-     * @var EE_Template_Config $template_config
71
-     */
72
-    protected $template_config;
73
-
74
-
75
-    /**
76
-     * CoreAssetRegister constructor.
77
-     *
78
-     * @param AssetCollection    $assets
79
-     * @param EE_Currency_Config $currency_config
80
-     * @param EE_Template_Config $template_config
81
-     * @param DomainInterface    $domain
82
-     * @param Registry           $registry
83
-     */
84
-    public function __construct(
85
-        AssetCollection $assets,
86
-        EE_Currency_Config $currency_config,
87
-        EE_Template_Config $template_config,
88
-        DomainInterface $domain,
89
-        Registry $registry
90
-    ) {
91
-        $this->currency_config = $currency_config;
92
-        $this->template_config = $template_config;
93
-        parent::__construct($domain, $assets, $registry);
94
-    }
95
-
96
-
97
-    /**
98
-     * @since 4.9.62.p
99
-     * @throws DuplicateCollectionIdentifierException
100
-     * @throws InvalidArgumentException
101
-     * @throws InvalidDataTypeException
102
-     * @throws InvalidEntityException
103
-     */
104
-    public function addAssets()
105
-    {
106
-        $this->addJavascriptFiles();
107
-        $this->addStylesheetFiles();
108
-    }
109
-
110
-
111
-    /**
112
-     * @since 4.9.62.p
113
-     * @throws DuplicateCollectionIdentifierException
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidEntityException
117
-     */
118
-    public function addJavascriptFiles()
119
-    {
120
-        $this->loadCoreJs();
121
-        $this->loadJqueryValidate();
122
-        $this->loadAccountingJs();
123
-        add_action(
124
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
125
-            array($this, 'loadQtipJs')
126
-        );
127
-        $this->registerAdminAssets();
128
-    }
129
-
130
-
131
-    /**
132
-     * @since 4.9.62.p
133
-     * @throws DuplicateCollectionIdentifierException
134
-     * @throws InvalidDataTypeException
135
-     * @throws InvalidEntityException
136
-     */
137
-    public function addStylesheetFiles()
138
-    {
139
-        $this->loadCoreCss();
140
-    }
141
-
142
-
143
-    /**
144
-     * core default javascript
145
-     *
146
-     * @since 4.9.62.p
147
-     * @throws DuplicateCollectionIdentifierException
148
-     * @throws InvalidArgumentException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     */
152
-    private function loadCoreJs()
153
-    {
154
-        $this->addJavascript(
155
-            CoreAssetManager::JS_HANDLE_EE_MANIFEST,
156
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
157
-        );
158
-
159
-        $this->addJavascript(
160
-            CoreAssetManager::JS_HANDLE_EE_JS_CORE,
161
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
162
-            array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
163
-        )
164
-        ->setHasLocalizedData();
165
-
166
-        $this->addJavascript(
167
-            CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT,
168
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'),
169
-            array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
170
-        );
171
-
172
-        global $wp_version;
173
-        if (version_compare($wp_version, '4.4.0', '>')) {
174
-            //js.api
175
-            $this->addJavascript(
176
-                CoreAssetManager::JS_HANDLE_EE_JS_API,
177
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
178
-                array(
179
-                    CoreAssetManager::JS_HANDLE_UNDERSCORE,
180
-                    CoreAssetManager::JS_HANDLE_EE_JS_CORE
181
-                )
182
-            );
183
-            $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
184
-            $this->registry->addData(
185
-                'paths',
186
-                array(
187
-                    'rest_route' => rest_url('ee/v4.8.36/'),
188
-                    'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
189
-                    'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()
190
-                )
191
-            );
192
-        }
193
-
194
-        $this->addJavascript(
195
-            CoreAssetManager::JS_HANDLE_EE_CORE,
196
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
197
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
198
-        )
199
-        ->setLocalizationCallback(
200
-            function () {
201
-                wp_localize_script(
202
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
203
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
204
-                    EE_Registry::$i18n_js_strings
205
-                );
206
-            }
207
-        );
208
-    }
209
-
210
-
211
-    /**
212
-     * @since 4.9.62.p
213
-     * @throws DuplicateCollectionIdentifierException
214
-     * @throws InvalidDataTypeException
215
-     * @throws InvalidEntityException
216
-     */
217
-    private function loadCoreCss()
218
-    {
219
-        if ($this->template_config->enable_default_style && ! is_admin()) {
220
-            $this->addStylesheet(
221
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
222
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
223
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
224
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
225
-                array('dashicons')
226
-            );
227
-            //Load custom style sheet if available
228
-            if ($this->template_config->custom_style_sheet !== null) {
229
-                $this->addStylesheet(
230
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
231
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
232
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
233
-                );
234
-            }
235
-        }
236
-    }
237
-
238
-
239
-    /**
240
-     * jQuery Validate for form validation
241
-     *
242
-     * @since 4.9.62.p
243
-     * @throws DuplicateCollectionIdentifierException
244
-     * @throws InvalidDataTypeException
245
-     * @throws InvalidEntityException
246
-     */
247
-    private function loadJqueryValidate()
248
-    {
249
-        $this->addJavascript(
250
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
251
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
252
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
253
-        )
254
-        ->setVersion('1.15.0');
255
-
256
-        $this->addJavascript(
257
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
258
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
259
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
260
-        )
261
-        ->setVersion('1.15.0');
262
-    }
263
-
264
-
265
-    /**
266
-     * accounting.js for performing client-side calculations
267
-     *
268
-     * @since 4.9.62.p
269
-     * @throws DuplicateCollectionIdentifierException
270
-     * @throws InvalidDataTypeException
271
-     * @throws InvalidEntityException
272
-     */
273
-    private function loadAccountingJs()
274
-    {
275
-        //accounting.js library
276
-        // @link http://josscrowcroft.github.io/accounting.js/
277
-        $this->addJavascript(
278
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
279
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
280
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
281
-        )
282
-        ->setVersion('0.3.2');
283
-
284
-        $currency_config = $this->currency_config;
285
-        $this->addJavascript(
286
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
287
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
288
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
289
-        )
290
-        ->setLocalizationCallback(
291
-            function () use ($currency_config) {
292
-                 wp_localize_script(
293
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
294
-                     'EE_ACCOUNTING_CFG',
295
-                     array(
296
-                         'currency' => array(
297
-                             'symbol'    => $currency_config->sign,
298
-                             'format'    => array(
299
-                                 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
300
-                                 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
301
-                                 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
302
-                             ),
303
-                             'decimal'   => $currency_config->dec_mrk,
304
-                             'thousand'  => $currency_config->thsnds,
305
-                             'precision' => $currency_config->dec_plc,
306
-                         ),
307
-                         'number'   => array(
308
-                             'precision' => $currency_config->dec_plc,
309
-                             'thousand'  => $currency_config->thsnds,
310
-                             'decimal'   => $currency_config->dec_mrk,
311
-                         ),
312
-                     )
313
-                 );
314
-            }
315
-        )
316
-        ->setVersion();
317
-    }
318
-
319
-
320
-    /**
321
-     * registers assets for cleaning your ears
322
-     *
323
-     * @param JavascriptAsset $script
324
-     */
325
-    public function loadQtipJs(JavascriptAsset $script)
326
-    {
327
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
328
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
329
-        if (
330
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
331
-            && apply_filters('FHEE_load_qtip', false)
332
-        ) {
333
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
334
-        }
335
-    }
336
-
337
-
338
-    /**
339
-     * assets that are used in the WordPress admin
340
-     *
341
-     * @since 4.9.62.p
342
-     * @throws DuplicateCollectionIdentifierException
343
-     * @throws InvalidDataTypeException
344
-     * @throws InvalidEntityException
345
-     */
346
-    private function registerAdminAssets()
347
-    {
348
-        $this->addJavascript(
349
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
350
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
351
-            array(
352
-                CoreAssetManager::JS_HANDLE_JQUERY,
353
-                CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT,
354
-            )
355
-        )
356
-        ->setRequiresTranslation();
357
-
358
-        $this->addStylesheet(
359
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
360
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
361
-        );
362
-    }
31
+	// WordPress core / Third party JS asset handles
32
+	const JS_HANDLE_JQUERY                = 'jquery';
33
+
34
+	const JS_HANDLE_JQUERY_VALIDATE       = 'jquery-validate';
35
+
36
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
37
+
38
+	const JS_HANDLE_UNDERSCORE            = 'underscore';
39
+
40
+	const JS_HANDLE_ACCOUNTING_CORE       = 'ee-accounting-core';
41
+
42
+	// EE JS assets handles
43
+	const JS_HANDLE_EE_MANIFEST        = 'ee-manifest';
44
+
45
+	const JS_HANDLE_EE_JS_CORE         = 'eejs-core';
46
+
47
+	const JS_HANDLE_EE_VENDOR_REACT    = 'ee-vendor-react';
48
+
49
+	const JS_HANDLE_EE_JS_API          = 'eejs-api';
50
+
51
+	const JS_HANDLE_EE_CORE            = 'espresso_core';
52
+
53
+	const JS_HANDLE_EE_I18N            = 'eei18n';
54
+
55
+	const JS_HANDLE_EE_ACCOUNTING      = 'ee-accounting';
56
+
57
+	const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
58
+
59
+	// EE CSS assets handles
60
+	const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
61
+
62
+	const CSS_HANDLE_EE_CUSTOM  = 'espresso_custom_css';
63
+
64
+	/**
65
+	 * @var EE_Currency_Config $currency_config
66
+	 */
67
+	protected $currency_config;
68
+
69
+	/**
70
+	 * @var EE_Template_Config $template_config
71
+	 */
72
+	protected $template_config;
73
+
74
+
75
+	/**
76
+	 * CoreAssetRegister constructor.
77
+	 *
78
+	 * @param AssetCollection    $assets
79
+	 * @param EE_Currency_Config $currency_config
80
+	 * @param EE_Template_Config $template_config
81
+	 * @param DomainInterface    $domain
82
+	 * @param Registry           $registry
83
+	 */
84
+	public function __construct(
85
+		AssetCollection $assets,
86
+		EE_Currency_Config $currency_config,
87
+		EE_Template_Config $template_config,
88
+		DomainInterface $domain,
89
+		Registry $registry
90
+	) {
91
+		$this->currency_config = $currency_config;
92
+		$this->template_config = $template_config;
93
+		parent::__construct($domain, $assets, $registry);
94
+	}
95
+
96
+
97
+	/**
98
+	 * @since 4.9.62.p
99
+	 * @throws DuplicateCollectionIdentifierException
100
+	 * @throws InvalidArgumentException
101
+	 * @throws InvalidDataTypeException
102
+	 * @throws InvalidEntityException
103
+	 */
104
+	public function addAssets()
105
+	{
106
+		$this->addJavascriptFiles();
107
+		$this->addStylesheetFiles();
108
+	}
109
+
110
+
111
+	/**
112
+	 * @since 4.9.62.p
113
+	 * @throws DuplicateCollectionIdentifierException
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidEntityException
117
+	 */
118
+	public function addJavascriptFiles()
119
+	{
120
+		$this->loadCoreJs();
121
+		$this->loadJqueryValidate();
122
+		$this->loadAccountingJs();
123
+		add_action(
124
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
125
+			array($this, 'loadQtipJs')
126
+		);
127
+		$this->registerAdminAssets();
128
+	}
129
+
130
+
131
+	/**
132
+	 * @since 4.9.62.p
133
+	 * @throws DuplicateCollectionIdentifierException
134
+	 * @throws InvalidDataTypeException
135
+	 * @throws InvalidEntityException
136
+	 */
137
+	public function addStylesheetFiles()
138
+	{
139
+		$this->loadCoreCss();
140
+	}
141
+
142
+
143
+	/**
144
+	 * core default javascript
145
+	 *
146
+	 * @since 4.9.62.p
147
+	 * @throws DuplicateCollectionIdentifierException
148
+	 * @throws InvalidArgumentException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 */
152
+	private function loadCoreJs()
153
+	{
154
+		$this->addJavascript(
155
+			CoreAssetManager::JS_HANDLE_EE_MANIFEST,
156
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
157
+		);
158
+
159
+		$this->addJavascript(
160
+			CoreAssetManager::JS_HANDLE_EE_JS_CORE,
161
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
162
+			array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
163
+		)
164
+		->setHasLocalizedData();
165
+
166
+		$this->addJavascript(
167
+			CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT,
168
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'),
169
+			array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
170
+		);
171
+
172
+		global $wp_version;
173
+		if (version_compare($wp_version, '4.4.0', '>')) {
174
+			//js.api
175
+			$this->addJavascript(
176
+				CoreAssetManager::JS_HANDLE_EE_JS_API,
177
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
178
+				array(
179
+					CoreAssetManager::JS_HANDLE_UNDERSCORE,
180
+					CoreAssetManager::JS_HANDLE_EE_JS_CORE
181
+				)
182
+			);
183
+			$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
184
+			$this->registry->addData(
185
+				'paths',
186
+				array(
187
+					'rest_route' => rest_url('ee/v4.8.36/'),
188
+					'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
189
+					'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()
190
+				)
191
+			);
192
+		}
193
+
194
+		$this->addJavascript(
195
+			CoreAssetManager::JS_HANDLE_EE_CORE,
196
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
197
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
198
+		)
199
+		->setLocalizationCallback(
200
+			function () {
201
+				wp_localize_script(
202
+					CoreAssetManager::JS_HANDLE_EE_CORE,
203
+					CoreAssetManager::JS_HANDLE_EE_I18N,
204
+					EE_Registry::$i18n_js_strings
205
+				);
206
+			}
207
+		);
208
+	}
209
+
210
+
211
+	/**
212
+	 * @since 4.9.62.p
213
+	 * @throws DuplicateCollectionIdentifierException
214
+	 * @throws InvalidDataTypeException
215
+	 * @throws InvalidEntityException
216
+	 */
217
+	private function loadCoreCss()
218
+	{
219
+		if ($this->template_config->enable_default_style && ! is_admin()) {
220
+			$this->addStylesheet(
221
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
222
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
223
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
224
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
225
+				array('dashicons')
226
+			);
227
+			//Load custom style sheet if available
228
+			if ($this->template_config->custom_style_sheet !== null) {
229
+				$this->addStylesheet(
230
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
231
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
232
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
233
+				);
234
+			}
235
+		}
236
+	}
237
+
238
+
239
+	/**
240
+	 * jQuery Validate for form validation
241
+	 *
242
+	 * @since 4.9.62.p
243
+	 * @throws DuplicateCollectionIdentifierException
244
+	 * @throws InvalidDataTypeException
245
+	 * @throws InvalidEntityException
246
+	 */
247
+	private function loadJqueryValidate()
248
+	{
249
+		$this->addJavascript(
250
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
251
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
252
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
253
+		)
254
+		->setVersion('1.15.0');
255
+
256
+		$this->addJavascript(
257
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
258
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
259
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
260
+		)
261
+		->setVersion('1.15.0');
262
+	}
263
+
264
+
265
+	/**
266
+	 * accounting.js for performing client-side calculations
267
+	 *
268
+	 * @since 4.9.62.p
269
+	 * @throws DuplicateCollectionIdentifierException
270
+	 * @throws InvalidDataTypeException
271
+	 * @throws InvalidEntityException
272
+	 */
273
+	private function loadAccountingJs()
274
+	{
275
+		//accounting.js library
276
+		// @link http://josscrowcroft.github.io/accounting.js/
277
+		$this->addJavascript(
278
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
279
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
280
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
281
+		)
282
+		->setVersion('0.3.2');
283
+
284
+		$currency_config = $this->currency_config;
285
+		$this->addJavascript(
286
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
287
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
288
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
289
+		)
290
+		->setLocalizationCallback(
291
+			function () use ($currency_config) {
292
+				 wp_localize_script(
293
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
294
+					 'EE_ACCOUNTING_CFG',
295
+					 array(
296
+						 'currency' => array(
297
+							 'symbol'    => $currency_config->sign,
298
+							 'format'    => array(
299
+								 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
300
+								 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
301
+								 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
302
+							 ),
303
+							 'decimal'   => $currency_config->dec_mrk,
304
+							 'thousand'  => $currency_config->thsnds,
305
+							 'precision' => $currency_config->dec_plc,
306
+						 ),
307
+						 'number'   => array(
308
+							 'precision' => $currency_config->dec_plc,
309
+							 'thousand'  => $currency_config->thsnds,
310
+							 'decimal'   => $currency_config->dec_mrk,
311
+						 ),
312
+					 )
313
+				 );
314
+			}
315
+		)
316
+		->setVersion();
317
+	}
318
+
319
+
320
+	/**
321
+	 * registers assets for cleaning your ears
322
+	 *
323
+	 * @param JavascriptAsset $script
324
+	 */
325
+	public function loadQtipJs(JavascriptAsset $script)
326
+	{
327
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
328
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
329
+		if (
330
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
331
+			&& apply_filters('FHEE_load_qtip', false)
332
+		) {
333
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
334
+		}
335
+	}
336
+
337
+
338
+	/**
339
+	 * assets that are used in the WordPress admin
340
+	 *
341
+	 * @since 4.9.62.p
342
+	 * @throws DuplicateCollectionIdentifierException
343
+	 * @throws InvalidDataTypeException
344
+	 * @throws InvalidEntityException
345
+	 */
346
+	private function registerAdminAssets()
347
+	{
348
+		$this->addJavascript(
349
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
350
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
351
+			array(
352
+				CoreAssetManager::JS_HANDLE_JQUERY,
353
+				CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT,
354
+			)
355
+		)
356
+		->setRequiresTranslation();
357
+
358
+		$this->addStylesheet(
359
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
360
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
361
+		);
362
+	}
363 363
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +985 added lines, -985 removed lines patch added patch discarded remove patch
@@ -20,989 +20,989 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        $class_name = $this->getFqnForAlias($class_name);
357
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
358
-    }
359
-
360
-
361
-    /**
362
-     * @return array
363
-     */
364
-    public function class_loaders()
365
-    {
366
-        return $this->_class_loaders;
367
-    }
368
-
369
-
370
-    /**
371
-     * adds an alias for a classname
372
-     *
373
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
374
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
375
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
376
-     */
377
-    public function add_alias($fqcn, $alias, $for_class = '')
378
-    {
379
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
380
-    }
381
-
382
-
383
-    /**
384
-     * Returns TRUE if the provided fully qualified name IS an alias
385
-     * WHY?
386
-     * Because if a class is type hinting for a concretion,
387
-     * then why would we need to find another class to supply it?
388
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
389
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
390
-     * Don't go looking for some substitute.
391
-     * Whereas if a class is type hinting for an interface...
392
-     * then we need to find an actual class to use.
393
-     * So the interface IS the alias for some other FQN,
394
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
395
-     * represents some other class.
396
-     *
397
-     * @param string $fqn
398
-     * @param string $for_class
399
-     * @return bool
400
-     */
401
-    public function isAlias($fqn = '', $for_class = '')
402
-    {
403
-        return $this->class_cache->isAlias($fqn, $for_class);
404
-    }
405
-
406
-
407
-    /**
408
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
409
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
410
-     *  for example:
411
-     *      if the following two entries were added to the _aliases array:
412
-     *          array(
413
-     *              'interface_alias'           => 'some\namespace\interface'
414
-     *              'some\namespace\interface'  => 'some\namespace\classname'
415
-     *          )
416
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
417
-     *      to load an instance of 'some\namespace\classname'
418
-     *
419
-     * @param string $alias
420
-     * @param string $for_class
421
-     * @return string
422
-     */
423
-    public function getFqnForAlias($alias = '', $for_class = '')
424
-    {
425
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
426
-    }
427
-
428
-
429
-    /**
430
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
-     * This is done by using the following class constants:
433
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
435
-     */
436
-    protected function _register_core_dependencies()
437
-    {
438
-        $this->_dependency_map = array(
439
-            'EE_Request_Handler'                                                                                          => array(
440
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_System'                                                                                                   => array(
443
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
444
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
445
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
446
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
447
-            ),
448
-            'EE_Session'                                                                                                  => array(
449
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
450
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
452
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
453
-            ),
454
-            'EE_Cart'                                                                                                     => array(
455
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
456
-            ),
457
-            'EE_Front_Controller'                                                                                         => array(
458
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
459
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
460
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Messenger_Collection_Loader'                                                                              => array(
463
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
464
-            ),
465
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
466
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
467
-            ),
468
-            'EE_Message_Resource_Manager'                                                                                 => array(
469
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
470
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
471
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
472
-            ),
473
-            'EE_Message_Factory'                                                                                          => array(
474
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
475
-            ),
476
-            'EE_messages'                                                                                                 => array(
477
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
478
-            ),
479
-            'EE_Messages_Generator'                                                                                       => array(
480
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
481
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
482
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
483
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
484
-            ),
485
-            'EE_Messages_Processor'                                                                                       => array(
486
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
-            ),
488
-            'EE_Messages_Queue'                                                                                           => array(
489
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
490
-            ),
491
-            'EE_Messages_Template_Defaults'                                                                               => array(
492
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
493
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
494
-            ),
495
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
496
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
497
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
498
-            ),
499
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
500
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
503
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
504
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
505
-            ),
506
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
507
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
508
-            ),
509
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
510
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
511
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
512
-            ),
513
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
514
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
-            ),
516
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
517
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
518
-            ),
519
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
520
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
521
-            ),
522
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
523
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
526
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
529
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
530
-            ),
531
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
532
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
533
-            ),
534
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
535
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
536
-            ),
537
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
538
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
-            ),
540
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
541
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
542
-            ),
543
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
544
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
545
-            ),
546
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
547
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
-            ),
549
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
550
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
551
-            ),
552
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
553
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
554
-            ),
555
-            'EE_Data_Migration_Class_Base'                                                                                => array(
556
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
557
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
558
-            ),
559
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
560
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
596
-                array(),
597
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
600
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
604
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
605
-            ),
606
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
607
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
608
-            ),
609
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
610
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
613
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
614
-            ),
615
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
616
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
617
-            ),
618
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
619
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
620
-            ),
621
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
622
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
623
-            ),
624
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
625
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
626
-            ),
627
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
628
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
629
-            ),
630
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
631
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
632
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
635
-                null,
636
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
637
-            ),
638
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
639
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
-            ),
641
-            'LEGACY_MODELS'                                                                                               => array(
642
-                null,
643
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
644
-            ),
645
-            'EE_Module_Request_Router'                                                                                    => array(
646
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
647
-            ),
648
-            'EE_Registration_Processor'                                                                                   => array(
649
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
652
-                null,
653
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
654
-                'EE_Request'                                                          => EE_Dependency_Map::load_from_cache,
655
-            ),
656
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
657
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
658
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
659
-            ),
660
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
661
-                null,
662
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
665
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
666
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
667
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
670
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
671
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
674
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
675
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
676
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
677
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
678
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
679
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
680
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
681
-            ),
682
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
683
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
684
-            ),
685
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
686
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
687
-            ),
688
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
689
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
690
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
691
-            ),
692
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
693
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
696
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
697
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
698
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
699
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
700
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
701
-            ),
702
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
703
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
706
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
707
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
708
-            ),
709
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
710
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
711
-            ),
712
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
713
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
714
-            ),
715
-            'EE_CPT_Strategy'                                                                                             => array(
716
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
717
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
718
-            ),
719
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
720
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
723
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
724
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
725
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
726
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
727
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
728
-            ),
729
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
730
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
731
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
732
-            ),
733
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
734
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
735
-            ),
736
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
737
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
738
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
739
-            ),
740
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
741
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
742
-            ),
743
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
744
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
747
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
748
-            ),
749
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
750
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
-            ),
752
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
753
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
754
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
757
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
758
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
759
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
760
-            ),
761
-            'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => array(
762
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
763
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
764
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
765
-            ),
766
-            'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
767
-                'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => self::load_from_cache,
768
-            ),
769
-        );
770
-    }
771
-
772
-
773
-    /**
774
-     * Registers how core classes are loaded.
775
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
776
-     *        'EE_Request_Handler' => 'load_core'
777
-     *        'EE_Messages_Queue'  => 'load_lib'
778
-     *        'EEH_Debug_Tools'    => 'load_helper'
779
-     * or, if greater control is required, by providing a custom closure. For example:
780
-     *        'Some_Class' => function () {
781
-     *            return new Some_Class();
782
-     *        },
783
-     * This is required for instantiating dependencies
784
-     * where an interface has been type hinted in a class constructor. For example:
785
-     *        'Required_Interface' => function () {
786
-     *            return new A_Class_That_Implements_Required_Interface();
787
-     *        },
788
-     */
789
-    protected function _register_core_class_loaders()
790
-    {
791
-        // for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
792
-        // be used in a closure.
793
-        $request = &$this->request;
794
-        $response = &$this->response;
795
-        $legacy_request = &$this->legacy_request;
796
-        // $loader = &$this->loader;
797
-        $this->_class_loaders = array(
798
-            // load_core
799
-            'EE_Capabilities'                              => 'load_core',
800
-            'EE_Encryption'                                => 'load_core',
801
-            'EE_Front_Controller'                          => 'load_core',
802
-            'EE_Module_Request_Router'                     => 'load_core',
803
-            'EE_Registry'                                  => 'load_core',
804
-            'EE_Request'                                   => function () use (&$legacy_request) {
805
-                return $legacy_request;
806
-            },
807
-            'EventEspresso\core\services\request\Request'  => function () use (&$request) {
808
-                return $request;
809
-            },
810
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
811
-                return $response;
812
-            },
813
-            'EE_Base'                                      => 'load_core',
814
-            'EE_Request_Handler'                           => 'load_core',
815
-            'EE_Session'                                   => 'load_core',
816
-            'EE_Cron_Tasks'                                => 'load_core',
817
-            'EE_System'                                    => 'load_core',
818
-            'EE_Maintenance_Mode'                          => 'load_core',
819
-            'EE_Register_CPTs'                             => 'load_core',
820
-            'EE_Admin'                                     => 'load_core',
821
-            'EE_CPT_Strategy'                              => 'load_core',
822
-            // load_lib
823
-            'EE_Message_Resource_Manager'                  => 'load_lib',
824
-            'EE_Message_Type_Collection'                   => 'load_lib',
825
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
826
-            'EE_Messenger_Collection'                      => 'load_lib',
827
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
828
-            'EE_Messages_Processor'                        => 'load_lib',
829
-            'EE_Message_Repository'                        => 'load_lib',
830
-            'EE_Messages_Queue'                            => 'load_lib',
831
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
832
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
833
-            'EE_Payment_Method_Manager'                    => 'load_lib',
834
-            'EE_Messages_Generator'                        => function () {
835
-                return EE_Registry::instance()->load_lib(
836
-                    'Messages_Generator',
837
-                    array(),
838
-                    false,
839
-                    false
840
-                );
841
-            },
842
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
843
-                return EE_Registry::instance()->load_lib(
844
-                    'Messages_Template_Defaults',
845
-                    $arguments,
846
-                    false,
847
-                    false
848
-                );
849
-            },
850
-            // load_helper
851
-            'EEH_Parse_Shortcodes'                         => function () {
852
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
853
-                    return new EEH_Parse_Shortcodes();
854
-                }
855
-                return null;
856
-            },
857
-            'EE_Template_Config'                           => function () {
858
-                return EE_Config::instance()->template_settings;
859
-            },
860
-            'EE_Currency_Config'                           => function () {
861
-                return EE_Config::instance()->currency;
862
-            },
863
-            'EE_Registration_Config'                       => function () {
864
-                return EE_Config::instance()->registration;
865
-            },
866
-            'EE_Core_Config'                               => function () {
867
-                return EE_Config::instance()->core;
868
-            },
869
-            'EventEspresso\core\services\loaders\Loader'   => function () {
870
-                return LoaderFactory::getLoader();
871
-            },
872
-            'EE_Network_Config'                            => function () {
873
-                return EE_Network_Config::instance();
874
-            },
875
-            'EE_Config'                                    => function () {
876
-                return EE_Config::instance();
877
-            },
878
-            'EventEspresso\core\domain\Domain'             => function () {
879
-                return DomainFactory::getEventEspressoCoreDomain();
880
-            },
881
-        );
882
-    }
883
-
884
-
885
-    /**
886
-     * can be used for supplying alternate names for classes,
887
-     * or for connecting interface names to instantiable classes
888
-     */
889
-    protected function _register_core_aliases()
890
-    {
891
-        $aliases = array(
892
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
893
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
894
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
895
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
896
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
897
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
898
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
899
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
900
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
901
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
902
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
903
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
904
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
905
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
906
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
907
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
908
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
909
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
910
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
911
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
912
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
913
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
914
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
915
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
916
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
917
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
918
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
919
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
920
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
921
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
922
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
923
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
924
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
925
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
926
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
927
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
928
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
929
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
930
-        );
931
-        foreach ($aliases as $alias => $fqn) {
932
-            if (is_array($fqn)) {
933
-                foreach ($fqn as $class => $for_class) {
934
-                    $this->class_cache->addAlias($class, $alias, $for_class);
935
-                }
936
-                continue;
937
-            }
938
-            $this->class_cache->addAlias($fqn, $alias);
939
-        }
940
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
941
-            $this->class_cache->addAlias(
942
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
943
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
944
-            );
945
-        }
946
-    }
947
-
948
-
949
-    /**
950
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
951
-     * request Primarily used by unit tests.
952
-     */
953
-    public function reset()
954
-    {
955
-        $this->_register_core_class_loaders();
956
-        $this->_register_core_dependencies();
957
-    }
958
-
959
-
960
-    /**
961
-     * PLZ NOTE: a better name for this method would be is_alias()
962
-     * because it returns TRUE if the provided fully qualified name IS an alias
963
-     * WHY?
964
-     * Because if a class is type hinting for a concretion,
965
-     * then why would we need to find another class to supply it?
966
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
967
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
968
-     * Don't go looking for some substitute.
969
-     * Whereas if a class is type hinting for an interface...
970
-     * then we need to find an actual class to use.
971
-     * So the interface IS the alias for some other FQN,
972
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
973
-     * represents some other class.
974
-     *
975
-     * @deprecated 4.9.62.p
976
-     * @param string $fqn
977
-     * @param string $for_class
978
-     * @return bool
979
-     */
980
-    public function has_alias($fqn = '', $for_class = '')
981
-    {
982
-        return $this->isAlias($fqn, $for_class);
983
-    }
984
-
985
-
986
-    /**
987
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
988
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
989
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
990
-     *  for example:
991
-     *      if the following two entries were added to the _aliases array:
992
-     *          array(
993
-     *              'interface_alias'           => 'some\namespace\interface'
994
-     *              'some\namespace\interface'  => 'some\namespace\classname'
995
-     *          )
996
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
997
-     *      to load an instance of 'some\namespace\classname'
998
-     *
999
-     * @deprecated 4.9.62.p
1000
-     * @param string $alias
1001
-     * @param string $for_class
1002
-     * @return string
1003
-     */
1004
-    public function get_alias($alias = '', $for_class = '')
1005
-    {
1006
-        return $this->getFqnForAlias($alias, $for_class);
1007
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		$class_name = $this->getFqnForAlias($class_name);
357
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
358
+	}
359
+
360
+
361
+	/**
362
+	 * @return array
363
+	 */
364
+	public function class_loaders()
365
+	{
366
+		return $this->_class_loaders;
367
+	}
368
+
369
+
370
+	/**
371
+	 * adds an alias for a classname
372
+	 *
373
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
374
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
375
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
376
+	 */
377
+	public function add_alias($fqcn, $alias, $for_class = '')
378
+	{
379
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
380
+	}
381
+
382
+
383
+	/**
384
+	 * Returns TRUE if the provided fully qualified name IS an alias
385
+	 * WHY?
386
+	 * Because if a class is type hinting for a concretion,
387
+	 * then why would we need to find another class to supply it?
388
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
389
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
390
+	 * Don't go looking for some substitute.
391
+	 * Whereas if a class is type hinting for an interface...
392
+	 * then we need to find an actual class to use.
393
+	 * So the interface IS the alias for some other FQN,
394
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
395
+	 * represents some other class.
396
+	 *
397
+	 * @param string $fqn
398
+	 * @param string $for_class
399
+	 * @return bool
400
+	 */
401
+	public function isAlias($fqn = '', $for_class = '')
402
+	{
403
+		return $this->class_cache->isAlias($fqn, $for_class);
404
+	}
405
+
406
+
407
+	/**
408
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
409
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
410
+	 *  for example:
411
+	 *      if the following two entries were added to the _aliases array:
412
+	 *          array(
413
+	 *              'interface_alias'           => 'some\namespace\interface'
414
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
415
+	 *          )
416
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
417
+	 *      to load an instance of 'some\namespace\classname'
418
+	 *
419
+	 * @param string $alias
420
+	 * @param string $for_class
421
+	 * @return string
422
+	 */
423
+	public function getFqnForAlias($alias = '', $for_class = '')
424
+	{
425
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
426
+	}
427
+
428
+
429
+	/**
430
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
+	 * This is done by using the following class constants:
433
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
435
+	 */
436
+	protected function _register_core_dependencies()
437
+	{
438
+		$this->_dependency_map = array(
439
+			'EE_Request_Handler'                                                                                          => array(
440
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_System'                                                                                                   => array(
443
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
444
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
445
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
446
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
447
+			),
448
+			'EE_Session'                                                                                                  => array(
449
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
450
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
452
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
453
+			),
454
+			'EE_Cart'                                                                                                     => array(
455
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
456
+			),
457
+			'EE_Front_Controller'                                                                                         => array(
458
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
459
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
460
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Messenger_Collection_Loader'                                                                              => array(
463
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
464
+			),
465
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
466
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
467
+			),
468
+			'EE_Message_Resource_Manager'                                                                                 => array(
469
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
470
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
471
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
472
+			),
473
+			'EE_Message_Factory'                                                                                          => array(
474
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
475
+			),
476
+			'EE_messages'                                                                                                 => array(
477
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
478
+			),
479
+			'EE_Messages_Generator'                                                                                       => array(
480
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
481
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
482
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
483
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
484
+			),
485
+			'EE_Messages_Processor'                                                                                       => array(
486
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
+			),
488
+			'EE_Messages_Queue'                                                                                           => array(
489
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
490
+			),
491
+			'EE_Messages_Template_Defaults'                                                                               => array(
492
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
493
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
494
+			),
495
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
496
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
497
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
498
+			),
499
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
500
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
503
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
504
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
505
+			),
506
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
507
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
508
+			),
509
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
510
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
511
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
512
+			),
513
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
514
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
+			),
516
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
517
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
518
+			),
519
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
520
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
521
+			),
522
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
523
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
526
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
529
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
530
+			),
531
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
532
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
533
+			),
534
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
535
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
536
+			),
537
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
538
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
+			),
540
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
541
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
542
+			),
543
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
544
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
545
+			),
546
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
547
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
+			),
549
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
550
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
551
+			),
552
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
553
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
554
+			),
555
+			'EE_Data_Migration_Class_Base'                                                                                => array(
556
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
557
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
558
+			),
559
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
560
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
596
+				array(),
597
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
600
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
604
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
605
+			),
606
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
607
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
608
+			),
609
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
610
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
613
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
614
+			),
615
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
616
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
617
+			),
618
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
619
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
620
+			),
621
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
622
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
623
+			),
624
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
625
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
626
+			),
627
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
628
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
629
+			),
630
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
631
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
632
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
635
+				null,
636
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
637
+			),
638
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
639
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
+			),
641
+			'LEGACY_MODELS'                                                                                               => array(
642
+				null,
643
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
644
+			),
645
+			'EE_Module_Request_Router'                                                                                    => array(
646
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
647
+			),
648
+			'EE_Registration_Processor'                                                                                   => array(
649
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
652
+				null,
653
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
654
+				'EE_Request'                                                          => EE_Dependency_Map::load_from_cache,
655
+			),
656
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
657
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
658
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
659
+			),
660
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
661
+				null,
662
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
665
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
666
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
667
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
670
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
671
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
674
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
675
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
676
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
677
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
678
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
679
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
680
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
681
+			),
682
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
683
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
684
+			),
685
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
686
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
687
+			),
688
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
689
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
690
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
691
+			),
692
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
693
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
696
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
697
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
698
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
699
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
700
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
701
+			),
702
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
703
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
706
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
707
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
708
+			),
709
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
710
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
711
+			),
712
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
713
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
714
+			),
715
+			'EE_CPT_Strategy'                                                                                             => array(
716
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
717
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
718
+			),
719
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
720
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
723
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
724
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
725
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
726
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
727
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
728
+			),
729
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
730
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
731
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
732
+			),
733
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
734
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
735
+			),
736
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
737
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
738
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
739
+			),
740
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
741
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
742
+			),
743
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
744
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
747
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
748
+			),
749
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
750
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
+			),
752
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
753
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
754
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
757
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
758
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
759
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
760
+			),
761
+			'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => array(
762
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
763
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
764
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
765
+			),
766
+			'EventEspresso\core\domain\entities\editor\blocks\widgets\EventAttendees' => array(
767
+				'EventEspresso\core\domain\entities\editor\blocks\CoreBlocksAssetManager' => self::load_from_cache,
768
+			),
769
+		);
770
+	}
771
+
772
+
773
+	/**
774
+	 * Registers how core classes are loaded.
775
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
776
+	 *        'EE_Request_Handler' => 'load_core'
777
+	 *        'EE_Messages_Queue'  => 'load_lib'
778
+	 *        'EEH_Debug_Tools'    => 'load_helper'
779
+	 * or, if greater control is required, by providing a custom closure. For example:
780
+	 *        'Some_Class' => function () {
781
+	 *            return new Some_Class();
782
+	 *        },
783
+	 * This is required for instantiating dependencies
784
+	 * where an interface has been type hinted in a class constructor. For example:
785
+	 *        'Required_Interface' => function () {
786
+	 *            return new A_Class_That_Implements_Required_Interface();
787
+	 *        },
788
+	 */
789
+	protected function _register_core_class_loaders()
790
+	{
791
+		// for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
792
+		// be used in a closure.
793
+		$request = &$this->request;
794
+		$response = &$this->response;
795
+		$legacy_request = &$this->legacy_request;
796
+		// $loader = &$this->loader;
797
+		$this->_class_loaders = array(
798
+			// load_core
799
+			'EE_Capabilities'                              => 'load_core',
800
+			'EE_Encryption'                                => 'load_core',
801
+			'EE_Front_Controller'                          => 'load_core',
802
+			'EE_Module_Request_Router'                     => 'load_core',
803
+			'EE_Registry'                                  => 'load_core',
804
+			'EE_Request'                                   => function () use (&$legacy_request) {
805
+				return $legacy_request;
806
+			},
807
+			'EventEspresso\core\services\request\Request'  => function () use (&$request) {
808
+				return $request;
809
+			},
810
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
811
+				return $response;
812
+			},
813
+			'EE_Base'                                      => 'load_core',
814
+			'EE_Request_Handler'                           => 'load_core',
815
+			'EE_Session'                                   => 'load_core',
816
+			'EE_Cron_Tasks'                                => 'load_core',
817
+			'EE_System'                                    => 'load_core',
818
+			'EE_Maintenance_Mode'                          => 'load_core',
819
+			'EE_Register_CPTs'                             => 'load_core',
820
+			'EE_Admin'                                     => 'load_core',
821
+			'EE_CPT_Strategy'                              => 'load_core',
822
+			// load_lib
823
+			'EE_Message_Resource_Manager'                  => 'load_lib',
824
+			'EE_Message_Type_Collection'                   => 'load_lib',
825
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
826
+			'EE_Messenger_Collection'                      => 'load_lib',
827
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
828
+			'EE_Messages_Processor'                        => 'load_lib',
829
+			'EE_Message_Repository'                        => 'load_lib',
830
+			'EE_Messages_Queue'                            => 'load_lib',
831
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
832
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
833
+			'EE_Payment_Method_Manager'                    => 'load_lib',
834
+			'EE_Messages_Generator'                        => function () {
835
+				return EE_Registry::instance()->load_lib(
836
+					'Messages_Generator',
837
+					array(),
838
+					false,
839
+					false
840
+				);
841
+			},
842
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
843
+				return EE_Registry::instance()->load_lib(
844
+					'Messages_Template_Defaults',
845
+					$arguments,
846
+					false,
847
+					false
848
+				);
849
+			},
850
+			// load_helper
851
+			'EEH_Parse_Shortcodes'                         => function () {
852
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
853
+					return new EEH_Parse_Shortcodes();
854
+				}
855
+				return null;
856
+			},
857
+			'EE_Template_Config'                           => function () {
858
+				return EE_Config::instance()->template_settings;
859
+			},
860
+			'EE_Currency_Config'                           => function () {
861
+				return EE_Config::instance()->currency;
862
+			},
863
+			'EE_Registration_Config'                       => function () {
864
+				return EE_Config::instance()->registration;
865
+			},
866
+			'EE_Core_Config'                               => function () {
867
+				return EE_Config::instance()->core;
868
+			},
869
+			'EventEspresso\core\services\loaders\Loader'   => function () {
870
+				return LoaderFactory::getLoader();
871
+			},
872
+			'EE_Network_Config'                            => function () {
873
+				return EE_Network_Config::instance();
874
+			},
875
+			'EE_Config'                                    => function () {
876
+				return EE_Config::instance();
877
+			},
878
+			'EventEspresso\core\domain\Domain'             => function () {
879
+				return DomainFactory::getEventEspressoCoreDomain();
880
+			},
881
+		);
882
+	}
883
+
884
+
885
+	/**
886
+	 * can be used for supplying alternate names for classes,
887
+	 * or for connecting interface names to instantiable classes
888
+	 */
889
+	protected function _register_core_aliases()
890
+	{
891
+		$aliases = array(
892
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
893
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
894
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
895
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
896
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
897
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
898
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
899
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
900
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
901
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
902
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
903
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
904
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
905
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
906
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
907
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
908
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
909
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
910
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
911
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
912
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
913
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
914
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
915
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
916
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
917
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
918
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
919
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
920
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
921
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
922
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
923
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
924
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
925
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
926
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
927
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
928
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
929
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
930
+		);
931
+		foreach ($aliases as $alias => $fqn) {
932
+			if (is_array($fqn)) {
933
+				foreach ($fqn as $class => $for_class) {
934
+					$this->class_cache->addAlias($class, $alias, $for_class);
935
+				}
936
+				continue;
937
+			}
938
+			$this->class_cache->addAlias($fqn, $alias);
939
+		}
940
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
941
+			$this->class_cache->addAlias(
942
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
943
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
944
+			);
945
+		}
946
+	}
947
+
948
+
949
+	/**
950
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
951
+	 * request Primarily used by unit tests.
952
+	 */
953
+	public function reset()
954
+	{
955
+		$this->_register_core_class_loaders();
956
+		$this->_register_core_dependencies();
957
+	}
958
+
959
+
960
+	/**
961
+	 * PLZ NOTE: a better name for this method would be is_alias()
962
+	 * because it returns TRUE if the provided fully qualified name IS an alias
963
+	 * WHY?
964
+	 * Because if a class is type hinting for a concretion,
965
+	 * then why would we need to find another class to supply it?
966
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
967
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
968
+	 * Don't go looking for some substitute.
969
+	 * Whereas if a class is type hinting for an interface...
970
+	 * then we need to find an actual class to use.
971
+	 * So the interface IS the alias for some other FQN,
972
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
973
+	 * represents some other class.
974
+	 *
975
+	 * @deprecated 4.9.62.p
976
+	 * @param string $fqn
977
+	 * @param string $for_class
978
+	 * @return bool
979
+	 */
980
+	public function has_alias($fqn = '', $for_class = '')
981
+	{
982
+		return $this->isAlias($fqn, $for_class);
983
+	}
984
+
985
+
986
+	/**
987
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
988
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
989
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
990
+	 *  for example:
991
+	 *      if the following two entries were added to the _aliases array:
992
+	 *          array(
993
+	 *              'interface_alias'           => 'some\namespace\interface'
994
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
995
+	 *          )
996
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
997
+	 *      to load an instance of 'some\namespace\classname'
998
+	 *
999
+	 * @deprecated 4.9.62.p
1000
+	 * @param string $alias
1001
+	 * @param string $for_class
1002
+	 * @return string
1003
+	 */
1004
+	public function get_alias($alias = '', $for_class = '')
1005
+	{
1006
+		return $this->getFqnForAlias($alias, $for_class);
1007
+	}
1008 1008
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.001');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.63.rc.001');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.