Completed
Branch BETA-4.9-messages-queue-fixed (941081)
by
unknown
30:24 queued 05:56
created

EE_Middleware::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
/**
3
 * Class EE_Middleware
4
 *
5
 * Parent class for EE_Middleware Request decorators.
6
 * Accepts an instance of another EE_Middleware class,
7
 * and handles the passing of EE_Request and EE_Response objects to and from it
8
 * EE_Middleware classes are for functionality that needs to run on nearly EVERY request.
9
 * They can perform their logic either before or after the core application has run:
10
 * 	(see documentation for the handle() method below)
11
 * EE_Middleware classes should NOT depend on core functionality,
12
 * because there is no guarantee that the core application has run
13
 *
14
 * @package 	Event Espresso
15
 * @subpackage 	core
16
 * @author 		Brent Christensen
17
 * @since       4.8.20
18
 *
19
 */
20
abstract class EE_Middleware implements EEI_Request_Decorator {
21
22
	/**
23
	 * @access 	protected
24
	 * @type    EEI_Request_Decorator $_request_stack
25
	 */
26
	protected $_request_stack = null;
27
28
	/**
29
	 * @access 	protected
30
	 * @type 	EE_Request $_request
31
	 */
32
	protected $_request;
33
34
	/**
35
	 * @access 	protected
36
	 * @type 	EE_Response $_response
37
	 */
38
	protected $_response;
39
40
41
42
	/**
43
	 * @access 	public
44
	 * @param 	\EEI_Request_Decorator $request_stack
45
	 */
46
	public function __construct( EEI_Request_Decorator $request_stack ) {
47
		$this->request_stack = $request_stack;
0 ignored issues
show
Bug introduced by
The property request_stack does not seem to exist. Did you mean _request_stack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
48
	}
49
50
51
52
	/**
53
	 * process_request_stack
54
	 *
55
	 * @access 	protected
56
	 * @param 	EE_Request  $request
57
	 * @param 	EE_Response $response
58
	 * @return 	EE_Response
59
	 */
60
	protected function process_request_stack( EE_Request $request, EE_Response $response ) {
61
		$this->_request = $request;
62
		$this->_response = $response;
63
		if ( ! $this->_response->request_terminated() ) {
64
			$this->_response = $this->request_stack->handle_request( $this->_request, $this->_response );
0 ignored issues
show
Bug introduced by
The property request_stack does not seem to exist. Did you mean _request_stack?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
65
		} else {
66
			espresso_deactivate_plugin( EE_PLUGIN_BASENAME );
67
		}
68
		return $this->_response;
69
	}
70
71
72
73
}
74
75
76
77
// End of file EE_Middleware.core.php
78
// Location: /core/middleware/EE_Middleware.core.php