Completed
Branch add-cap-checks-to-routes (ab085a)
by
unknown
20:06 queued 12:34
created
core/services/commands/registration/CreateRegistrationCommand.php 1 patch
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -24,151 +24,151 @@
 block discarded – undo
24 24
  */
25 25
 class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface
26 26
 {
27
-    /**
28
-     * @var EE_Transaction $transaction
29
-     */
30
-    private $transaction;
31
-
32
-    /**
33
-     * @var EE_Ticket $ticket
34
-     */
35
-    private $ticket;
36
-
37
-    /**
38
-     * @var EE_Line_Item $ticket_line_item
39
-     */
40
-    private $ticket_line_item;
41
-
42
-    /**
43
-     * @var int $reg_count
44
-     */
45
-    private $reg_count;
46
-
47
-    /**
48
-     * @var int $reg_group_size
49
-     */
50
-    private $reg_group_size;
51
-
52
-    /**
53
-     * @var string $reg_status
54
-     */
55
-    private $reg_status;
56
-
57
-    /**
58
-     * @var EE_Registration $registration
59
-     */
60
-    protected $registration;
61
-
62
-
63
-    /**
64
-     * CreateRegistrationCommand constructor.
65
-     *
66
-     * @param EE_Transaction $transaction
67
-     * @param EE_Line_Item   $ticket_line_item
68
-     * @param int            $reg_count
69
-     * @param int            $reg_group_size
70
-     * @param string         $reg_status
71
-     * @throws InvalidEntityException
72
-     */
73
-    public function __construct(
74
-        EE_Transaction $transaction,
75
-        EE_Line_Item $ticket_line_item,
76
-        $reg_count = 1,
77
-        $reg_group_size = 0,
78
-        $reg_status = EEM_Registration::status_id_incomplete
79
-    ) {
80
-        // grab the related ticket object for this line_item
81
-        $this->ticket = $ticket_line_item->ticket();
82
-        if (! $this->ticket instanceof EE_Ticket) {
83
-            throw new InvalidEntityException(
84
-                is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
-                'EE_Ticket',
86
-                sprintf(
87
-                    esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
88
-                    $ticket_line_item->ID()
89
-                )
90
-            );
91
-        }
92
-        $this->transaction = $transaction;
93
-        $this->ticket_line_item = $ticket_line_item;
94
-        $this->reg_count = absint($reg_count);
95
-        $this->reg_group_size = absint($reg_group_size);
96
-        $this->reg_status = $reg_status;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return CapCheckInterface
102
-     * @throws InvalidDataTypeException
103
-     */
104
-    public function getCapCheck()
105
-    {
106
-        if (! $this->cap_check instanceof CapCheckInterface) {
107
-            return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
-        }
109
-        return $this->cap_check;
110
-    }
111
-
112
-
113
-    /**
114
-     * @return EE_Transaction
115
-     */
116
-    public function transaction()
117
-    {
118
-        return $this->transaction;
119
-    }
120
-
121
-
122
-    /**
123
-     * @return EE_Ticket
124
-     */
125
-    public function ticket()
126
-    {
127
-        return $this->ticket;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return EE_Line_Item
133
-     */
134
-    public function ticketLineItem()
135
-    {
136
-        return $this->ticket_line_item;
137
-    }
138
-
139
-
140
-    /**
141
-     * @return int
142
-     */
143
-    public function regCount()
144
-    {
145
-        return $this->reg_count;
146
-    }
147
-
148
-
149
-    /**
150
-     * @return int
151
-     */
152
-    public function regGroupSize()
153
-    {
154
-        return $this->reg_group_size;
155
-    }
156
-
157
-
158
-    /**
159
-     * @return string
160
-     */
161
-    public function regStatus()
162
-    {
163
-        return $this->reg_status;
164
-    }
165
-
166
-
167
-    /**
168
-     * @return EE_Registration
169
-     */
170
-    public function registration()
171
-    {
172
-        return $this->registration;
173
-    }
27
+	/**
28
+	 * @var EE_Transaction $transaction
29
+	 */
30
+	private $transaction;
31
+
32
+	/**
33
+	 * @var EE_Ticket $ticket
34
+	 */
35
+	private $ticket;
36
+
37
+	/**
38
+	 * @var EE_Line_Item $ticket_line_item
39
+	 */
40
+	private $ticket_line_item;
41
+
42
+	/**
43
+	 * @var int $reg_count
44
+	 */
45
+	private $reg_count;
46
+
47
+	/**
48
+	 * @var int $reg_group_size
49
+	 */
50
+	private $reg_group_size;
51
+
52
+	/**
53
+	 * @var string $reg_status
54
+	 */
55
+	private $reg_status;
56
+
57
+	/**
58
+	 * @var EE_Registration $registration
59
+	 */
60
+	protected $registration;
61
+
62
+
63
+	/**
64
+	 * CreateRegistrationCommand constructor.
65
+	 *
66
+	 * @param EE_Transaction $transaction
67
+	 * @param EE_Line_Item   $ticket_line_item
68
+	 * @param int            $reg_count
69
+	 * @param int            $reg_group_size
70
+	 * @param string         $reg_status
71
+	 * @throws InvalidEntityException
72
+	 */
73
+	public function __construct(
74
+		EE_Transaction $transaction,
75
+		EE_Line_Item $ticket_line_item,
76
+		$reg_count = 1,
77
+		$reg_group_size = 0,
78
+		$reg_status = EEM_Registration::status_id_incomplete
79
+	) {
80
+		// grab the related ticket object for this line_item
81
+		$this->ticket = $ticket_line_item->ticket();
82
+		if (! $this->ticket instanceof EE_Ticket) {
83
+			throw new InvalidEntityException(
84
+				is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
+				'EE_Ticket',
86
+				sprintf(
87
+					esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
88
+					$ticket_line_item->ID()
89
+				)
90
+			);
91
+		}
92
+		$this->transaction = $transaction;
93
+		$this->ticket_line_item = $ticket_line_item;
94
+		$this->reg_count = absint($reg_count);
95
+		$this->reg_group_size = absint($reg_group_size);
96
+		$this->reg_status = $reg_status;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return CapCheckInterface
102
+	 * @throws InvalidDataTypeException
103
+	 */
104
+	public function getCapCheck()
105
+	{
106
+		if (! $this->cap_check instanceof CapCheckInterface) {
107
+			return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
+		}
109
+		return $this->cap_check;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return EE_Transaction
115
+	 */
116
+	public function transaction()
117
+	{
118
+		return $this->transaction;
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return EE_Ticket
124
+	 */
125
+	public function ticket()
126
+	{
127
+		return $this->ticket;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return EE_Line_Item
133
+	 */
134
+	public function ticketLineItem()
135
+	{
136
+		return $this->ticket_line_item;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @return int
142
+	 */
143
+	public function regCount()
144
+	{
145
+		return $this->reg_count;
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return int
151
+	 */
152
+	public function regGroupSize()
153
+	{
154
+		return $this->reg_group_size;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return string
160
+	 */
161
+	public function regStatus()
162
+	{
163
+		return $this->reg_status;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return EE_Registration
169
+	 */
170
+	public function registration()
171
+	{
172
+		return $this->registration;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
core/services/commands/CommandRequiresCapCheckInterface.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
  */
14 14
 interface CommandRequiresCapCheckInterface
15 15
 {
16
-    /**
17
-     * @return CapCheckInterface
18
-     */
19
-    public function getCapCheck();
16
+	/**
17
+	 * @return CapCheckInterface
18
+	 */
19
+	public function getCapCheck();
20 20
 }
Please login to merge, or discard this patch.
core/services/routing/RouteHandler.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -21,182 +21,182 @@
 block discarded – undo
21 21
  */
22 22
 class RouteHandler
23 23
 {
24
-    /**
25
-     * @var CapabilitiesCheckerInterface $capabilities_checker
26
-     */
27
-    private $capabilities_checker;
28
-
29
-    /**
30
-     * @var JsonDataNodeHandler $data_node_handler
31
-     */
32
-    private $data_node_handler;
33
-
34
-    /**
35
-     * @var LoaderInterface $loader
36
-     */
37
-    private $loader;
38
-
39
-    /**
40
-     * @var RequestInterface $request
41
-     */
42
-    protected $request;
43
-
44
-    /**
45
-     * @var RouteCollection $routes
46
-     */
47
-    private $routes;
48
-
49
-    /**
50
-     * @var boolean $print_data_nodes
51
-     */
52
-    private $print_data_nodes = true;
53
-
54
-    /**
55
-     * @var string $route_request_type
56
-     */
57
-    protected $route_request_type = '';
58
-
59
-
60
-    /**
61
-     * RouteHandler constructor.
62
-     *
63
-     * @param CapabilitiesCheckerInterface $capabilities_checker
64
-     * @param JsonDataNodeHandler $data_node_handler
65
-     * @param LoaderInterface     $loader
66
-     * @param RequestInterface    $request
67
-     * @param RouteCollection     $routes
68
-     */
69
-    public function __construct(
70
-        CapabilitiesCheckerInterface $capabilities_checker,
71
-        JsonDataNodeHandler $data_node_handler,
72
-        LoaderInterface $loader,
73
-        RequestInterface $request,
74
-        RouteCollection $routes
75
-    ) {
76
-        $this->capabilities_checker = $capabilities_checker;
77
-        $this->data_node_handler = $data_node_handler;
78
-        $this->loader            = $loader;
79
-        $this->request           = $request;
80
-        $this->routes            = $routes;
81
-    }
82
-
83
-
84
-    /**
85
-     * @param string $fqcn   Fully Qualified Class Name for Route
86
-     * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
87
-     * @throws Exception
88
-     */
89
-    public function addRoute(string $fqcn, bool $handle = true)
90
-    {
91
-        try {
92
-            $route = $this->loader->getShared($fqcn);
93
-            $this->validateRoute($route, $fqcn);
94
-            if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) {
95
-                $this->routes->add($route);
96
-                $this->handle($route, $handle);
97
-            }
98
-        } catch (Exception $exception) {
99
-            new ExceptionStackTraceDisplay(
100
-                new DomainException(
101
-                    sprintf(
102
-                        esc_html__(
103
-                            'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s',
104
-                            'event_espresso'
105
-                        ),
106
-                        $fqcn,
107
-                        '<br />',
108
-                        $exception->getMessage()
109
-                    )
110
-                )
111
-            );
112
-        }
113
-    }
114
-
115
-
116
-    /**
117
-     * @return string
118
-     */
119
-    public function getRouteRequestType(): string
120
-    {
121
-        return $this->route_request_type;
122
-    }
123
-
124
-
125
-    /**
126
-     * @param string $route_request_type
127
-     */
128
-    public function setRouteRequestType(string $route_request_type = '')
129
-    {
130
-        $this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RouteInterface $route
136
-     * @param bool           $handle if true [default] will immediately call RouteInterface::handleRequest()
137
-     */
138
-    public function handle(RouteInterface $route, bool $handle = true)
139
-    {
140
-        if ($handle && $route->isNotHandled()) {
141
-            $route->handleRequest();
142
-            if ($route instanceof PrimaryRoute) {
143
-                $this->setRouteRequestType($route->getRouteRequestType());
144
-            }
145
-            $data_node = $route->dataNode();
146
-            if ($data_node instanceof JsonDataNode) {
147
-                $this->data_node_handler->addDataNode($data_node);
148
-                $this->printDataNodes();
149
-            }
150
-        }
151
-    }
152
-
153
-
154
-    /**
155
-     * calls RouteInterface::handleRequest() on all Routes that
156
-     *      - match current request
157
-     *      - have yet to be handled
158
-     *
159
-     * @return void
160
-     */
161
-    public function handleRoutesForCurrentRequest()
162
-    {
163
-        $this->routes->handleRoutesForCurrentRequest();
164
-    }
165
-
166
-
167
-    /**
168
-     * @return void
169
-     */
170
-    private function printDataNodes()
171
-    {
172
-        if ($this->print_data_nodes) {
173
-            add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0);
174
-            add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0);
175
-            $this->print_data_nodes = false;
176
-        }
177
-    }
178
-
179
-
180
-    /**
181
-     * @param RouteInterface|null $route
182
-     * @param string              $fqcn
183
-     */
184
-    private function validateRoute(?RouteInterface $route, string $fqcn = '')
185
-    {
186
-        if (! $route instanceof RouteInterface) {
187
-            throw new InvalidClassException(
188
-                sprintf(
189
-                    /*
24
+	/**
25
+	 * @var CapabilitiesCheckerInterface $capabilities_checker
26
+	 */
27
+	private $capabilities_checker;
28
+
29
+	/**
30
+	 * @var JsonDataNodeHandler $data_node_handler
31
+	 */
32
+	private $data_node_handler;
33
+
34
+	/**
35
+	 * @var LoaderInterface $loader
36
+	 */
37
+	private $loader;
38
+
39
+	/**
40
+	 * @var RequestInterface $request
41
+	 */
42
+	protected $request;
43
+
44
+	/**
45
+	 * @var RouteCollection $routes
46
+	 */
47
+	private $routes;
48
+
49
+	/**
50
+	 * @var boolean $print_data_nodes
51
+	 */
52
+	private $print_data_nodes = true;
53
+
54
+	/**
55
+	 * @var string $route_request_type
56
+	 */
57
+	protected $route_request_type = '';
58
+
59
+
60
+	/**
61
+	 * RouteHandler constructor.
62
+	 *
63
+	 * @param CapabilitiesCheckerInterface $capabilities_checker
64
+	 * @param JsonDataNodeHandler $data_node_handler
65
+	 * @param LoaderInterface     $loader
66
+	 * @param RequestInterface    $request
67
+	 * @param RouteCollection     $routes
68
+	 */
69
+	public function __construct(
70
+		CapabilitiesCheckerInterface $capabilities_checker,
71
+		JsonDataNodeHandler $data_node_handler,
72
+		LoaderInterface $loader,
73
+		RequestInterface $request,
74
+		RouteCollection $routes
75
+	) {
76
+		$this->capabilities_checker = $capabilities_checker;
77
+		$this->data_node_handler = $data_node_handler;
78
+		$this->loader            = $loader;
79
+		$this->request           = $request;
80
+		$this->routes            = $routes;
81
+	}
82
+
83
+
84
+	/**
85
+	 * @param string $fqcn   Fully Qualified Class Name for Route
86
+	 * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
87
+	 * @throws Exception
88
+	 */
89
+	public function addRoute(string $fqcn, bool $handle = true)
90
+	{
91
+		try {
92
+			$route = $this->loader->getShared($fqcn);
93
+			$this->validateRoute($route, $fqcn);
94
+			if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) {
95
+				$this->routes->add($route);
96
+				$this->handle($route, $handle);
97
+			}
98
+		} catch (Exception $exception) {
99
+			new ExceptionStackTraceDisplay(
100
+				new DomainException(
101
+					sprintf(
102
+						esc_html__(
103
+							'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s',
104
+							'event_espresso'
105
+						),
106
+						$fqcn,
107
+						'<br />',
108
+						$exception->getMessage()
109
+					)
110
+				)
111
+			);
112
+		}
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return string
118
+	 */
119
+	public function getRouteRequestType(): string
120
+	{
121
+		return $this->route_request_type;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param string $route_request_type
127
+	 */
128
+	public function setRouteRequestType(string $route_request_type = '')
129
+	{
130
+		$this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RouteInterface $route
136
+	 * @param bool           $handle if true [default] will immediately call RouteInterface::handleRequest()
137
+	 */
138
+	public function handle(RouteInterface $route, bool $handle = true)
139
+	{
140
+		if ($handle && $route->isNotHandled()) {
141
+			$route->handleRequest();
142
+			if ($route instanceof PrimaryRoute) {
143
+				$this->setRouteRequestType($route->getRouteRequestType());
144
+			}
145
+			$data_node = $route->dataNode();
146
+			if ($data_node instanceof JsonDataNode) {
147
+				$this->data_node_handler->addDataNode($data_node);
148
+				$this->printDataNodes();
149
+			}
150
+		}
151
+	}
152
+
153
+
154
+	/**
155
+	 * calls RouteInterface::handleRequest() on all Routes that
156
+	 *      - match current request
157
+	 *      - have yet to be handled
158
+	 *
159
+	 * @return void
160
+	 */
161
+	public function handleRoutesForCurrentRequest()
162
+	{
163
+		$this->routes->handleRoutesForCurrentRequest();
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return void
169
+	 */
170
+	private function printDataNodes()
171
+	{
172
+		if ($this->print_data_nodes) {
173
+			add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0);
174
+			add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0);
175
+			$this->print_data_nodes = false;
176
+		}
177
+	}
178
+
179
+
180
+	/**
181
+	 * @param RouteInterface|null $route
182
+	 * @param string              $fqcn
183
+	 */
184
+	private function validateRoute(?RouteInterface $route, string $fqcn = '')
185
+	{
186
+		if (! $route instanceof RouteInterface) {
187
+			throw new InvalidClassException(
188
+				sprintf(
189
+					/*
190 190
                      * translators:
191 191
                      * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface.
192 192
                      */
193
-                    esc_html__(
194
-                        'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
195
-                        'event_espresso'
196
-                    ),
197
-                    $fqcn
198
-                )
199
-            );
200
-        }
201
-    }
193
+					esc_html__(
194
+						'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
195
+						'event_espresso'
196
+					),
197
+					$fqcn
198
+				)
199
+			);
200
+		}
201
+	}
202 202
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
      */
184 184
     private function validateRoute(?RouteInterface $route, string $fqcn = '')
185 185
     {
186
-        if (! $route instanceof RouteInterface) {
186
+        if ( ! $route instanceof RouteInterface) {
187 187
             throw new InvalidClassException(
188 188
                 sprintf(
189 189
                     /*
Please login to merge, or discard this patch.
core/services/routing/Route.php 1 patch
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -28,271 +28,271 @@
 block discarded – undo
28 28
  */
29 29
 abstract class Route implements RouteInterface, RequiresCapCheckInterface
30 30
 {
31
-    /**
32
-     * @var AssetManagerInterface $asset_manager
33
-     */
34
-    protected $asset_manager;
35
-
36
-    /**
37
-     * @var EE_Dependency_Map $dependency_map
38
-     */
39
-    protected $dependency_map;
40
-
41
-    /**
42
-     * @var JsonDataNode $data_node
43
-     */
44
-    protected $data_node;
45
-
46
-    /**
47
-     * @var LoaderInterface $loader
48
-     */
49
-    protected $loader;
50
-
51
-    /**
52
-     * @var RequestInterface $request
53
-     */
54
-    protected $request;
55
-
56
-    /**
57
-     * @var RouteMatchSpecificationInterface $specification
58
-     */
59
-    protected $specification;
60
-
61
-    /**
62
-     * @var boolean $handled
63
-     */
64
-    private $handled = false;
65
-
66
-    /**
67
-     * @var array $default_dependencies
68
-     */
69
-    protected static $default_dependencies = [
70
-        'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
71
-        'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
72
-        'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
73
-    ];
74
-
75
-    /**
76
-     * @var array $full_dependencies
77
-     */
78
-    protected static $full_dependencies = [
79
-        'EE_Dependency_Map'                             => EE_Dependency_Map::load_from_cache,
80
-        'EventEspresso\core\services\loaders\Loader'    => EE_Dependency_Map::load_from_cache,
81
-        'EventEspresso\core\services\request\Request'   => EE_Dependency_Map::load_from_cache,
82
-        'EventEspresso\core\services\json\JsonDataNode' => EE_Dependency_Map::load_from_cache,
83
-        RouteMatchSpecificationInterface::class         => EE_Dependency_Map::load_from_cache,
84
-    ];
85
-
86
-
87
-    /**
88
-     * Route constructor.
89
-     *
90
-     * @param EE_Dependency_Map                     $dependency_map
91
-     * @param LoaderInterface                       $loader
92
-     * @param RequestInterface                      $request
93
-     * @param JsonDataNode|null                     $data_node
94
-     * @param RouteMatchSpecificationInterface|null $specification
95
-     */
96
-    public function __construct(
97
-        EE_Dependency_Map $dependency_map,
98
-        LoaderInterface $loader,
99
-        RequestInterface $request,
100
-        JsonDataNode $data_node = null,
101
-        RouteMatchSpecificationInterface $specification = null
102
-    ) {
103
-        $this->dependency_map = $dependency_map;
104
-        $this->data_node      = $data_node;
105
-        $this->loader         = $loader;
106
-        $this->request        = $request;
107
-        $this->setSpecification($specification);
108
-    }
109
-
110
-
111
-    /**
112
-     * @return void
113
-     */
114
-    abstract protected function registerDependencies();
115
-
116
-
117
-    /**
118
-     * implements logic required to run during request
119
-     *
120
-     * @return bool
121
-     */
122
-    abstract protected function requestHandler(): bool;
123
-
124
-
125
-    /**
126
-     * called just before matchesCurrentRequest()
127
-     * and allows Route to perform any setup required such as calling setSpecification()
128
-     *
129
-     * @return void
130
-     */
131
-    public function initialize()
132
-    {
133
-        // do nothing by default
134
-    }
135
-
136
-
137
-    /**
138
-     * returns true if the current request matches this route
139
-     * child classes can override and use Request directly to match route with request
140
-     * or supply a RouteMatchSpecification class and just use the below
141
-     *
142
-     * @return bool
143
-     */
144
-    public function matchesCurrentRequest(): bool
145
-    {
146
-        return $this->specification instanceof RouteMatchSpecificationInterface
147
-               && $this->specification->isMatchingRoute();
148
-    }
149
-
150
-
151
-    /**
152
-     * returns the FQCN for this route's JsonDataNode
153
-     *
154
-     * @return string
155
-     */
156
-    protected function dataNodeClass(): string
157
-    {
158
-        return '';
159
-    }
160
-
161
-
162
-    public function getCapCheck()
163
-    {
164
-        return new PublicCapabilities('', 'access Event Espresso route');
165
-    }
166
-
167
-
168
-    /**
169
-     * @return array
170
-     */
171
-    public static function getDefaultDependencies(): array
172
-    {
173
-        return self::$default_dependencies;
174
-    }
175
-
176
-
177
-    /**
178
-     * @return array
179
-     */
180
-    public static function getFullDependencies(): array
181
-    {
182
-        return self::$full_dependencies;
183
-    }
184
-
185
-
186
-    /**
187
-     * @param JsonDataNode|null $data_node
188
-     */
189
-    protected function setDataNode(JsonDataNode $data_node = null)
190
-    {
191
-        $this->data_node = $data_node;
192
-    }
193
-
194
-
195
-    /**
196
-     * @param RouteMatchSpecificationInterface|null $specification
197
-     */
198
-    protected function setSpecification(RouteMatchSpecificationInterface $specification = null)
199
-    {
200
-        $this->specification = $specification;
201
-    }
202
-
203
-
204
-    /**
205
-     * @return JsonDataNode
206
-     */
207
-    public function dataNode(): ?JsonDataNode
208
-    {
209
-        return $this->data_node;
210
-    }
211
-
212
-
213
-    /**
214
-     * runs route requestHandler() if
215
-     *      - route has not previously been handled
216
-     *      - route specification matches for current request
217
-     * sets route handled property based on results returned by requestHandler()
218
-     *
219
-     * @return bool
220
-     */
221
-    public function handleRequest(): bool
222
-    {
223
-        if ($this->isNotHandled()) {
224
-            $this->initialize();
225
-            if ($this->matchesCurrentRequest()) {
226
-                do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this);
227
-                $this->registerDependencies();
228
-                $this->loadDataNode();
229
-                $this->verifyIsHandled($this->requestHandler());
230
-            }
231
-        }
232
-        return $this->handled;
233
-    }
234
-
235
-
236
-    /**
237
-     * @return bool
238
-     */
239
-    final public function isHandled(): bool
240
-    {
241
-        return $this->handled;
242
-    }
243
-
244
-
245
-    /**
246
-     * @return bool
247
-     */
248
-    final public function isNotHandled(): bool
249
-    {
250
-        return ! $this->handled;
251
-    }
252
-
253
-
254
-    /**
255
-     * @return void
256
-     */
257
-    private function loadDataNode()
258
-    {
259
-        $data_node_fqcn = $this->dataNodeClass();
260
-        if (! empty($data_node_fqcn)) {
261
-            $data_node = $this->loader->getShared($data_node_fqcn);
262
-            $this->setDataNode($data_node);
263
-        }
264
-    }
265
-
266
-
267
-    /**
268
-     * @param string $domain_fqcn
269
-     */
270
-    public function initializeBaristaForDomain(string $domain_fqcn)
271
-    {
272
-        if (apply_filters('FHEE__load_Barista', true)) {
273
-            /** @var BaristaFactory $factory */
274
-            $factory = $this->loader->getShared(BaristaFactory::class);
275
-            $barista = $factory->createFromDomainClass($domain_fqcn);
276
-            if ($barista instanceof BaristaInterface) {
277
-                $barista->initialize();
278
-            }
279
-        }
280
-    }
281
-
282
-
283
-    /**
284
-     * @var bool
285
-     */
286
-    private function verifyIsHandled($handled)
287
-    {
288
-        if (! is_bool($handled)) {
289
-            throw new DomainException(
290
-                esc_html__(
291
-                    'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.',
292
-                    'event_espresso'
293
-                )
294
-            );
295
-        }
296
-        $this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN);
297
-    }
31
+	/**
32
+	 * @var AssetManagerInterface $asset_manager
33
+	 */
34
+	protected $asset_manager;
35
+
36
+	/**
37
+	 * @var EE_Dependency_Map $dependency_map
38
+	 */
39
+	protected $dependency_map;
40
+
41
+	/**
42
+	 * @var JsonDataNode $data_node
43
+	 */
44
+	protected $data_node;
45
+
46
+	/**
47
+	 * @var LoaderInterface $loader
48
+	 */
49
+	protected $loader;
50
+
51
+	/**
52
+	 * @var RequestInterface $request
53
+	 */
54
+	protected $request;
55
+
56
+	/**
57
+	 * @var RouteMatchSpecificationInterface $specification
58
+	 */
59
+	protected $specification;
60
+
61
+	/**
62
+	 * @var boolean $handled
63
+	 */
64
+	private $handled = false;
65
+
66
+	/**
67
+	 * @var array $default_dependencies
68
+	 */
69
+	protected static $default_dependencies = [
70
+		'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
71
+		'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
72
+		'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
73
+	];
74
+
75
+	/**
76
+	 * @var array $full_dependencies
77
+	 */
78
+	protected static $full_dependencies = [
79
+		'EE_Dependency_Map'                             => EE_Dependency_Map::load_from_cache,
80
+		'EventEspresso\core\services\loaders\Loader'    => EE_Dependency_Map::load_from_cache,
81
+		'EventEspresso\core\services\request\Request'   => EE_Dependency_Map::load_from_cache,
82
+		'EventEspresso\core\services\json\JsonDataNode' => EE_Dependency_Map::load_from_cache,
83
+		RouteMatchSpecificationInterface::class         => EE_Dependency_Map::load_from_cache,
84
+	];
85
+
86
+
87
+	/**
88
+	 * Route constructor.
89
+	 *
90
+	 * @param EE_Dependency_Map                     $dependency_map
91
+	 * @param LoaderInterface                       $loader
92
+	 * @param RequestInterface                      $request
93
+	 * @param JsonDataNode|null                     $data_node
94
+	 * @param RouteMatchSpecificationInterface|null $specification
95
+	 */
96
+	public function __construct(
97
+		EE_Dependency_Map $dependency_map,
98
+		LoaderInterface $loader,
99
+		RequestInterface $request,
100
+		JsonDataNode $data_node = null,
101
+		RouteMatchSpecificationInterface $specification = null
102
+	) {
103
+		$this->dependency_map = $dependency_map;
104
+		$this->data_node      = $data_node;
105
+		$this->loader         = $loader;
106
+		$this->request        = $request;
107
+		$this->setSpecification($specification);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return void
113
+	 */
114
+	abstract protected function registerDependencies();
115
+
116
+
117
+	/**
118
+	 * implements logic required to run during request
119
+	 *
120
+	 * @return bool
121
+	 */
122
+	abstract protected function requestHandler(): bool;
123
+
124
+
125
+	/**
126
+	 * called just before matchesCurrentRequest()
127
+	 * and allows Route to perform any setup required such as calling setSpecification()
128
+	 *
129
+	 * @return void
130
+	 */
131
+	public function initialize()
132
+	{
133
+		// do nothing by default
134
+	}
135
+
136
+
137
+	/**
138
+	 * returns true if the current request matches this route
139
+	 * child classes can override and use Request directly to match route with request
140
+	 * or supply a RouteMatchSpecification class and just use the below
141
+	 *
142
+	 * @return bool
143
+	 */
144
+	public function matchesCurrentRequest(): bool
145
+	{
146
+		return $this->specification instanceof RouteMatchSpecificationInterface
147
+			   && $this->specification->isMatchingRoute();
148
+	}
149
+
150
+
151
+	/**
152
+	 * returns the FQCN for this route's JsonDataNode
153
+	 *
154
+	 * @return string
155
+	 */
156
+	protected function dataNodeClass(): string
157
+	{
158
+		return '';
159
+	}
160
+
161
+
162
+	public function getCapCheck()
163
+	{
164
+		return new PublicCapabilities('', 'access Event Espresso route');
165
+	}
166
+
167
+
168
+	/**
169
+	 * @return array
170
+	 */
171
+	public static function getDefaultDependencies(): array
172
+	{
173
+		return self::$default_dependencies;
174
+	}
175
+
176
+
177
+	/**
178
+	 * @return array
179
+	 */
180
+	public static function getFullDependencies(): array
181
+	{
182
+		return self::$full_dependencies;
183
+	}
184
+
185
+
186
+	/**
187
+	 * @param JsonDataNode|null $data_node
188
+	 */
189
+	protected function setDataNode(JsonDataNode $data_node = null)
190
+	{
191
+		$this->data_node = $data_node;
192
+	}
193
+
194
+
195
+	/**
196
+	 * @param RouteMatchSpecificationInterface|null $specification
197
+	 */
198
+	protected function setSpecification(RouteMatchSpecificationInterface $specification = null)
199
+	{
200
+		$this->specification = $specification;
201
+	}
202
+
203
+
204
+	/**
205
+	 * @return JsonDataNode
206
+	 */
207
+	public function dataNode(): ?JsonDataNode
208
+	{
209
+		return $this->data_node;
210
+	}
211
+
212
+
213
+	/**
214
+	 * runs route requestHandler() if
215
+	 *      - route has not previously been handled
216
+	 *      - route specification matches for current request
217
+	 * sets route handled property based on results returned by requestHandler()
218
+	 *
219
+	 * @return bool
220
+	 */
221
+	public function handleRequest(): bool
222
+	{
223
+		if ($this->isNotHandled()) {
224
+			$this->initialize();
225
+			if ($this->matchesCurrentRequest()) {
226
+				do_action('AHEE__EventEspresso_core_domain_entities_routes_handlers_Route__handleRequest', $this);
227
+				$this->registerDependencies();
228
+				$this->loadDataNode();
229
+				$this->verifyIsHandled($this->requestHandler());
230
+			}
231
+		}
232
+		return $this->handled;
233
+	}
234
+
235
+
236
+	/**
237
+	 * @return bool
238
+	 */
239
+	final public function isHandled(): bool
240
+	{
241
+		return $this->handled;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @return bool
247
+	 */
248
+	final public function isNotHandled(): bool
249
+	{
250
+		return ! $this->handled;
251
+	}
252
+
253
+
254
+	/**
255
+	 * @return void
256
+	 */
257
+	private function loadDataNode()
258
+	{
259
+		$data_node_fqcn = $this->dataNodeClass();
260
+		if (! empty($data_node_fqcn)) {
261
+			$data_node = $this->loader->getShared($data_node_fqcn);
262
+			$this->setDataNode($data_node);
263
+		}
264
+	}
265
+
266
+
267
+	/**
268
+	 * @param string $domain_fqcn
269
+	 */
270
+	public function initializeBaristaForDomain(string $domain_fqcn)
271
+	{
272
+		if (apply_filters('FHEE__load_Barista', true)) {
273
+			/** @var BaristaFactory $factory */
274
+			$factory = $this->loader->getShared(BaristaFactory::class);
275
+			$barista = $factory->createFromDomainClass($domain_fqcn);
276
+			if ($barista instanceof BaristaInterface) {
277
+				$barista->initialize();
278
+			}
279
+		}
280
+	}
281
+
282
+
283
+	/**
284
+	 * @var bool
285
+	 */
286
+	private function verifyIsHandled($handled)
287
+	{
288
+		if (! is_bool($handled)) {
289
+			throw new DomainException(
290
+				esc_html__(
291
+					'Route::requestHandler() must return a boolean to indicate whether the request has been handled or not.',
292
+					'event_espresso'
293
+				)
294
+			);
295
+		}
296
+		$this->handled = filter_var($handled, FILTER_VALIDATE_BOOLEAN);
297
+	}
298 298
 }
Please login to merge, or discard this patch.
core/domain/services/capabilities/CapCheck.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -14,63 +14,63 @@
 block discarded – undo
14 14
  */
15 15
 class CapCheck implements CapCheckInterface
16 16
 {
17
-    /**
18
-     * @var string|array $capability
19
-     */
20
-    private $capability;
17
+	/**
18
+	 * @var string|array $capability
19
+	 */
20
+	private $capability;
21 21
 
22
-    /**
23
-     * @var string $context
24
-     */
25
-    private $context;
22
+	/**
23
+	 * @var string $context
24
+	 */
25
+	private $context;
26 26
 
27
-    /**
28
-     * @var int|string $ID
29
-     */
30
-    private $ID;
27
+	/**
28
+	 * @var int|string $ID
29
+	 */
30
+	private $ID;
31 31
 
32 32
 
33
-    /**
34
-     * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
35
-     *                                     or an array of capability strings
36
-     * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
37
-     * @param int|string   $ID           - (optional) ID for item where current_user_can is being called from
38
-     * @throws InvalidDataTypeException
39
-     */
40
-    public function __construct($capability, string $context, $ID = 0)
41
-    {
42
-        if (! (is_string($capability) || is_array($capability))) {
43
-            throw new InvalidDataTypeException('$capability', $capability, 'string or array');
44
-        }
45
-        $this->capability = $capability;
46
-        $this->context = strtolower(str_replace(' ', '_', $context));
47
-        $this->ID = $ID;
48
-    }
33
+	/**
34
+	 * @param string|array $capability   - the capability to be checked, like: 'ee_edit_registrations',
35
+	 *                                     or an array of capability strings
36
+	 * @param string       $context      - what the user is attempting to do, like: 'Edit Registration'
37
+	 * @param int|string   $ID           - (optional) ID for item where current_user_can is being called from
38
+	 * @throws InvalidDataTypeException
39
+	 */
40
+	public function __construct($capability, string $context, $ID = 0)
41
+	{
42
+		if (! (is_string($capability) || is_array($capability))) {
43
+			throw new InvalidDataTypeException('$capability', $capability, 'string or array');
44
+		}
45
+		$this->capability = $capability;
46
+		$this->context = strtolower(str_replace(' ', '_', $context));
47
+		$this->ID = $ID;
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * @return string|array
53
-     */
54
-    public function capability()
55
-    {
56
-        return $this->capability;
57
-    }
51
+	/**
52
+	 * @return string|array
53
+	 */
54
+	public function capability()
55
+	{
56
+		return $this->capability;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return string
62
-     */
63
-    public function context(): string
64
-    {
65
-        return $this->context;
66
-    }
60
+	/**
61
+	 * @return string
62
+	 */
63
+	public function context(): string
64
+	{
65
+		return $this->context;
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * @return int|string
71
-     */
72
-    public function ID()
73
-    {
74
-        return $this->ID;
75
-    }
69
+	/**
70
+	 * @return int|string
71
+	 */
72
+	public function ID()
73
+	{
74
+		return $this->ID;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
      */
40 40
     public function __construct($capability, string $context, $ID = 0)
41 41
     {
42
-        if (! (is_string($capability) || is_array($capability))) {
42
+        if ( ! (is_string($capability) || is_array($capability))) {
43 43
             throw new InvalidDataTypeException('$capability', $capability, 'string or array');
44 44
         }
45 45
         $this->capability = $capability;
Please login to merge, or discard this patch.
core/domain/services/capabilities/CapabilitiesChecker.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -17,94 +17,94 @@
 block discarded – undo
17 17
  */
18 18
 class CapabilitiesChecker implements CapabilitiesCheckerInterface
19 19
 {
20
-    /**
21
-     * @type EE_Capabilities $capabilities
22
-     */
23
-    private $capabilities;
20
+	/**
21
+	 * @type EE_Capabilities $capabilities
22
+	 */
23
+	private $capabilities;
24 24
 
25 25
 
26
-    /**
27
-     * CapabilitiesChecker constructor
28
-     *
29
-     * @param EE_Capabilities $capabilities
30
-     */
31
-    public function __construct(EE_Capabilities $capabilities)
32
-    {
33
-        $this->capabilities = $capabilities;
34
-    }
26
+	/**
27
+	 * CapabilitiesChecker constructor
28
+	 *
29
+	 * @param EE_Capabilities $capabilities
30
+	 */
31
+	public function __construct(EE_Capabilities $capabilities)
32
+	{
33
+		$this->capabilities = $capabilities;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @return EE_Capabilities
39
-     */
40
-    protected function capabilities(): EE_Capabilities
41
-    {
42
-        return $this->capabilities;
43
-    }
37
+	/**
38
+	 * @return EE_Capabilities
39
+	 */
40
+	protected function capabilities(): EE_Capabilities
41
+	{
42
+		return $this->capabilities;
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO.
48
-     * If any of the individual capability checks fails, then the command will NOT be executed.
49
-     *
50
-     * @param CapCheckInterface|CapCheckInterface[] $cap_check
51
-     * @param bool                                  $suppress_exceptions
52
-     * @return bool
53
-     * @throws InvalidClassException
54
-     * @throws InsufficientPermissionsException
55
-     */
56
-    public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool
57
-    {
58
-        if (is_array($cap_check)) {
59
-            $passed = true;
60
-            foreach ($cap_check as $check) {
61
-                $passed = $this->processCapCheck($check) ? $passed : false;
62
-            }
63
-            return $passed;
64
-        }
65
-        // at this point, $cap_check should be an individual instance of CapCheck
66
-        if (! $cap_check instanceof CapCheckInterface) {
67
-            if ($suppress_exceptions) {
68
-                return false;
69
-            }
70
-            throw new InvalidClassException(
71
-                '\EventEspresso\core\domain\services\capabilities\CapCheckInterface'
72
-            );
73
-        }
74
-        // sometimes cap checks are conditional, and no capabilities are required
75
-        if ($cap_check instanceof PublicCapabilities) {
76
-            return true;
77
-        }
78
-        $capabilities = (array) $cap_check->capability();
79
-        foreach ($capabilities as $capability) {
80
-            if (
81
-                ! $this->capabilities()->current_user_can(
82
-                    $capability,
83
-                    $cap_check->context(),
84
-                    $cap_check->ID()
85
-                )
86
-            ) {
87
-                if ($suppress_exceptions) {
88
-                    return false;
89
-                }
90
-                throw new InsufficientPermissionsException($cap_check->context());
91
-            }
92
-        }
93
-        return true;
94
-    }
46
+	/**
47
+	 * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO.
48
+	 * If any of the individual capability checks fails, then the command will NOT be executed.
49
+	 *
50
+	 * @param CapCheckInterface|CapCheckInterface[] $cap_check
51
+	 * @param bool                                  $suppress_exceptions
52
+	 * @return bool
53
+	 * @throws InvalidClassException
54
+	 * @throws InsufficientPermissionsException
55
+	 */
56
+	public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool
57
+	{
58
+		if (is_array($cap_check)) {
59
+			$passed = true;
60
+			foreach ($cap_check as $check) {
61
+				$passed = $this->processCapCheck($check) ? $passed : false;
62
+			}
63
+			return $passed;
64
+		}
65
+		// at this point, $cap_check should be an individual instance of CapCheck
66
+		if (! $cap_check instanceof CapCheckInterface) {
67
+			if ($suppress_exceptions) {
68
+				return false;
69
+			}
70
+			throw new InvalidClassException(
71
+				'\EventEspresso\core\domain\services\capabilities\CapCheckInterface'
72
+			);
73
+		}
74
+		// sometimes cap checks are conditional, and no capabilities are required
75
+		if ($cap_check instanceof PublicCapabilities) {
76
+			return true;
77
+		}
78
+		$capabilities = (array) $cap_check->capability();
79
+		foreach ($capabilities as $capability) {
80
+			if (
81
+				! $this->capabilities()->current_user_can(
82
+					$capability,
83
+					$cap_check->context(),
84
+					$cap_check->ID()
85
+				)
86
+			) {
87
+				if ($suppress_exceptions) {
88
+					return false;
89
+				}
90
+				throw new InsufficientPermissionsException($cap_check->context());
91
+			}
92
+		}
93
+		return true;
94
+	}
95 95
 
96 96
 
97
-    /**
98
-     * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations'
99
-     * @param string       $context    - what the user is attempting to do, like: 'Edit Registration'
100
-     * @param int|string   $ID         - (optional) ID for item where current_user_can is being called from
101
-     * @return bool
102
-     * @throws InvalidDataTypeException
103
-     * @throws InsufficientPermissionsException
104
-     * @throws InvalidClassException
105
-     */
106
-    public function process($capability, string $context, $ID = 0): bool
107
-    {
108
-        return $this->processCapCheck(new CapCheck($capability, $context, $ID));
109
-    }
97
+	/**
98
+	 * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations'
99
+	 * @param string       $context    - what the user is attempting to do, like: 'Edit Registration'
100
+	 * @param int|string   $ID         - (optional) ID for item where current_user_can is being called from
101
+	 * @return bool
102
+	 * @throws InvalidDataTypeException
103
+	 * @throws InsufficientPermissionsException
104
+	 * @throws InvalidClassException
105
+	 */
106
+	public function process($capability, string $context, $ID = 0): bool
107
+	{
108
+		return $this->processCapCheck(new CapCheck($capability, $context, $ID));
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
             return $passed;
64 64
         }
65 65
         // at this point, $cap_check should be an individual instance of CapCheck
66
-        if (! $cap_check instanceof CapCheckInterface) {
66
+        if ( ! $cap_check instanceof CapCheckInterface) {
67 67
             if ($suppress_exceptions) {
68 68
                 return false;
69 69
             }
Please login to merge, or discard this patch.
core/domain/services/capabilities/CapabilitiesCheckerInterface.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
  */
16 16
 interface CapabilitiesCheckerInterface
17 17
 {
18
-    /**
19
-     * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO.
20
-     * If any of the individual capability checks fails, then the command will NOT be executed.
21
-     *
22
-     * @param CapCheckInterface|CapCheckInterface[] $cap_check
23
-     * @param bool                                  $suppress_exceptions
24
-     * @return bool
25
-     * @throws InvalidClassException
26
-     * @throws InsufficientPermissionsException
27
-     */
28
-    public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool;
18
+	/**
19
+	 * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO.
20
+	 * If any of the individual capability checks fails, then the command will NOT be executed.
21
+	 *
22
+	 * @param CapCheckInterface|CapCheckInterface[] $cap_check
23
+	 * @param bool                                  $suppress_exceptions
24
+	 * @return bool
25
+	 * @throws InvalidClassException
26
+	 * @throws InsufficientPermissionsException
27
+	 */
28
+	public function processCapCheck($cap_check, bool $suppress_exceptions = false): bool;
29 29
 
30 30
 
31
-    /**
32
-     * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations'
33
-     * @param string $context    - what the user is attempting to do, like: 'Edit Registration'
34
-     * @param int|string    $ID         - (optional) ID for item where current_user_can is being called from
35
-     * @return bool
36
-     * @throws InsufficientPermissionsException
37
-     * @throws InvalidClassException
38
-     */
39
-    public function process($capability, string $context, $ID = 0): bool;
31
+	/**
32
+	 * @param array|string $capability - the capability to be checked, like: 'ee_edit_registrations'
33
+	 * @param string $context    - what the user is attempting to do, like: 'Edit Registration'
34
+	 * @param int|string    $ID         - (optional) ID for item where current_user_can is being called from
35
+	 * @return bool
36
+	 * @throws InsufficientPermissionsException
37
+	 * @throws InvalidClassException
38
+	 */
39
+	public function process($capability, string $context, $ID = 0): bool;
40 40
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/admin/ActivationRequests.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,47 +15,47 @@
 block discarded – undo
15 15
  */
16 16
 class ActivationRequests extends PrimaryRoute
17 17
 {
18
-    /**
19
-     * returns true if the current request matches this route
20
-     *
21
-     * @return bool
22
-     * @since   $VID:$
23
-     */
24
-    public function matchesCurrentRequest(): bool
25
-    {
26
-        return $this->request->isActivation();
27
-    }
18
+	/**
19
+	 * returns true if the current request matches this route
20
+	 *
21
+	 * @return bool
22
+	 * @since   $VID:$
23
+	 */
24
+	public function matchesCurrentRequest(): bool
25
+	{
26
+		return $this->request->isActivation();
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @since $VID:$
32
-     */
33
-    protected function registerDependencies()
34
-    {
35
-        $this->dependency_map->registerDependencies(
36
-            'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute',
37
-            AdminRoute::getDefaultDependencies()
38
-        );
39
-        $this->dependency_map->registerDependencies(
40
-            'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests',
41
-            Route::getDefaultDependencies()
42
-        );
43
-        $this->dependency_map->registerDependencies(
44
-            'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage',
45
-            Route::getDefaultDependencies()
46
-        );
47
-    }
30
+	/**
31
+	 * @since $VID:$
32
+	 */
33
+	protected function registerDependencies()
34
+	{
35
+		$this->dependency_map->registerDependencies(
36
+			'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute',
37
+			AdminRoute::getDefaultDependencies()
38
+		);
39
+		$this->dependency_map->registerDependencies(
40
+			'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests',
41
+			Route::getDefaultDependencies()
42
+		);
43
+		$this->dependency_map->registerDependencies(
44
+			'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage',
45
+			Route::getDefaultDependencies()
46
+		);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * implements logic required to run during request
52
-     *
53
-     * @return bool
54
-     * @since   $VID:$
55
-     */
56
-    protected function requestHandler(): bool
57
-    {
58
-        $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION);
59
-        return true;
60
-    }
50
+	/**
51
+	 * implements logic required to run during request
52
+	 *
53
+	 * @return bool
54
+	 * @since   $VID:$
55
+	 */
56
+	protected function requestHandler(): bool
57
+	{
58
+		$this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION);
59
+		return true;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/admin/AdminRoute.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -26,88 +26,88 @@
 block discarded – undo
26 26
  */
27 27
 class AdminRoute extends Route
28 28
 {
29
-    /**
30
-     * @var EE_Admin_Config $admin_config
31
-     */
32
-    protected $admin_config;
33
-
34
-    /**
35
-     * @var array $default_dependencies
36
-     */
37
-    protected static $default_dependencies = [
38
-        'EE_Admin_Config'                             => EE_Dependency_Map::load_from_cache,
39
-        'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
40
-        'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
41
-        'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
42
-    ];
43
-
44
-
45
-    /**
46
-     * Route constructor.
47
-     *
48
-     * @param EE_Admin_Config                       $admin_config
49
-     * @param EE_Dependency_Map                     $dependency_map
50
-     * @param LoaderInterface                       $loader
51
-     * @param RequestInterface                      $request
52
-     * @param JsonDataNode|null                     $data_node
53
-     * @param RouteMatchSpecificationInterface|null $specification
54
-     */
55
-    public function __construct(
56
-        EE_Admin_Config $admin_config,
57
-        EE_Dependency_Map $dependency_map,
58
-        LoaderInterface $loader,
59
-        RequestInterface $request,
60
-        JsonDataNode $data_node = null,
61
-        RouteMatchSpecificationInterface $specification = null
62
-    ) {
63
-        $this->admin_config = $admin_config;
64
-        parent::__construct($dependency_map, $loader, $request, $data_node, $specification);
65
-    }
66
-
67
-
68
-    public function getCapCheck()
69
-    {
70
-        return new CapCheck('edit_posts', 'access Event Espresso admin route');
71
-    }
72
-
73
-
74
-    /**
75
-     * @return array
76
-     */
77
-    public static function getDefaultDependencies(): array
78
-    {
79
-        return self::$default_dependencies;
80
-    }
81
-
82
-
83
-    /**
84
-     * returns true if the current request matches this route
85
-     *
86
-     * @return bool
87
-     */
88
-    public function matchesCurrentRequest(): bool
89
-    {
90
-        return $this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation();
91
-    }
92
-
93
-
94
-    /**
95
-     * @return void
96
-     */
97
-    protected function registerDependencies()
98
-    {
99
-    }
100
-
101
-
102
-    /**
103
-     * implements logic required to run during request
104
-     *
105
-     * @return bool
106
-     */
107
-    protected function requestHandler(): bool
108
-    {
109
-        do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
110
-        $this->loader->getShared('EE_Admin');
111
-        return true;
112
-    }
29
+	/**
30
+	 * @var EE_Admin_Config $admin_config
31
+	 */
32
+	protected $admin_config;
33
+
34
+	/**
35
+	 * @var array $default_dependencies
36
+	 */
37
+	protected static $default_dependencies = [
38
+		'EE_Admin_Config'                             => EE_Dependency_Map::load_from_cache,
39
+		'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
40
+		'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
41
+		'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
42
+	];
43
+
44
+
45
+	/**
46
+	 * Route constructor.
47
+	 *
48
+	 * @param EE_Admin_Config                       $admin_config
49
+	 * @param EE_Dependency_Map                     $dependency_map
50
+	 * @param LoaderInterface                       $loader
51
+	 * @param RequestInterface                      $request
52
+	 * @param JsonDataNode|null                     $data_node
53
+	 * @param RouteMatchSpecificationInterface|null $specification
54
+	 */
55
+	public function __construct(
56
+		EE_Admin_Config $admin_config,
57
+		EE_Dependency_Map $dependency_map,
58
+		LoaderInterface $loader,
59
+		RequestInterface $request,
60
+		JsonDataNode $data_node = null,
61
+		RouteMatchSpecificationInterface $specification = null
62
+	) {
63
+		$this->admin_config = $admin_config;
64
+		parent::__construct($dependency_map, $loader, $request, $data_node, $specification);
65
+	}
66
+
67
+
68
+	public function getCapCheck()
69
+	{
70
+		return new CapCheck('edit_posts', 'access Event Espresso admin route');
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return array
76
+	 */
77
+	public static function getDefaultDependencies(): array
78
+	{
79
+		return self::$default_dependencies;
80
+	}
81
+
82
+
83
+	/**
84
+	 * returns true if the current request matches this route
85
+	 *
86
+	 * @return bool
87
+	 */
88
+	public function matchesCurrentRequest(): bool
89
+	{
90
+		return $this->request->isAdmin() || $this->request->isAdminAjax() || $this->request->isActivation();
91
+	}
92
+
93
+
94
+	/**
95
+	 * @return void
96
+	 */
97
+	protected function registerDependencies()
98
+	{
99
+	}
100
+
101
+
102
+	/**
103
+	 * implements logic required to run during request
104
+	 *
105
+	 * @return bool
106
+	 */
107
+	protected function requestHandler(): bool
108
+	{
109
+		do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
110
+		$this->loader->getShared('EE_Admin');
111
+		return true;
112
+	}
113 113
 }
Please login to merge, or discard this patch.