@@ -13,8 +13,8 @@ |
||
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 | } |
@@ -183,7 +183,7 @@ |
||
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 | /* |
@@ -22,161 +22,161 @@ |
||
22 | 22 | */ |
23 | 23 | class RouteHandler |
24 | 24 | { |
25 | - private CapabilitiesCheckerInterface $capabilities_checker; |
|
26 | - |
|
27 | - private JsonDataNodeHandler $data_node_handler; |
|
28 | - |
|
29 | - private LoaderInterface $loader; |
|
30 | - |
|
31 | - protected RequestInterface $request; |
|
32 | - |
|
33 | - private RouteCollection $routes; |
|
34 | - |
|
35 | - private bool $print_data_nodes = true; |
|
36 | - |
|
37 | - protected string $route_request_type = ''; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * RouteHandler constructor. |
|
42 | - * |
|
43 | - * @param CapabilitiesCheckerInterface $capabilities_checker |
|
44 | - * @param JsonDataNodeHandler $data_node_handler |
|
45 | - * @param LoaderInterface $loader |
|
46 | - * @param RequestInterface $request |
|
47 | - * @param RouteCollection $routes |
|
48 | - */ |
|
49 | - public function __construct( |
|
50 | - CapabilitiesCheckerInterface $capabilities_checker, |
|
51 | - JsonDataNodeHandler $data_node_handler, |
|
52 | - LoaderInterface $loader, |
|
53 | - RequestInterface $request, |
|
54 | - RouteCollection $routes |
|
55 | - ) { |
|
56 | - $this->capabilities_checker = $capabilities_checker; |
|
57 | - $this->data_node_handler = $data_node_handler; |
|
58 | - $this->loader = $loader; |
|
59 | - $this->request = $request; |
|
60 | - $this->routes = $routes; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @param string $fqcn Fully Qualified Class Name for Route |
|
66 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
67 | - * @throws Exception|Throwable |
|
68 | - */ |
|
69 | - public function addRoute(string $fqcn, bool $handle = true) |
|
70 | - { |
|
71 | - try { |
|
72 | - $route = $this->loader->getShared($fqcn); |
|
73 | - $this->validateRoute($route, $fqcn); |
|
74 | - if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) { |
|
75 | - $this->routes->add($route); |
|
76 | - $this->handle($route, $handle); |
|
77 | - } |
|
78 | - } catch (Exception $exception) { |
|
79 | - new ExceptionStackTraceDisplay( |
|
80 | - new DomainException( |
|
81 | - sprintf( |
|
82 | - esc_html__( |
|
83 | - 'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s', |
|
84 | - 'event_espresso' |
|
85 | - ), |
|
86 | - $fqcn, |
|
87 | - '<br />', |
|
88 | - $exception->getMessage() |
|
89 | - ) |
|
90 | - ) |
|
91 | - ); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function getRouteRequestType(): string |
|
100 | - { |
|
101 | - return $this->route_request_type; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @param string $route_request_type |
|
107 | - */ |
|
108 | - public function setRouteRequestType(string $route_request_type = '') |
|
109 | - { |
|
110 | - $this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param RouteInterface $route |
|
116 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
117 | - */ |
|
118 | - public function handle(RouteInterface $route, bool $handle = true) |
|
119 | - { |
|
120 | - if ($handle && $route->isNotHandled()) { |
|
121 | - $route->handleRequest(); |
|
122 | - if ($route instanceof PrimaryRoute) { |
|
123 | - $this->setRouteRequestType($route->getRouteRequestType()); |
|
124 | - } |
|
125 | - $data_node = $route->dataNode(); |
|
126 | - if ($data_node instanceof JsonDataNode) { |
|
127 | - $this->data_node_handler->addDataNode($data_node); |
|
128 | - $this->printDataNodes(); |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * calls RouteInterface::handleRequest() on all Routes that |
|
136 | - * - match current request |
|
137 | - * - have yet to be handled |
|
138 | - * |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - public function handleRoutesForCurrentRequest() |
|
142 | - { |
|
143 | - $this->routes->handleRoutesForCurrentRequest(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @return void |
|
149 | - */ |
|
150 | - private function printDataNodes() |
|
151 | - { |
|
152 | - if ($this->print_data_nodes) { |
|
153 | - add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
154 | - add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
155 | - $this->print_data_nodes = false; |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * @param RouteInterface|null $route |
|
162 | - * @param string $fqcn |
|
163 | - */ |
|
164 | - private function validateRoute(?RouteInterface $route, string $fqcn = '') |
|
165 | - { |
|
166 | - if (! $route instanceof RouteInterface) { |
|
167 | - throw new InvalidClassException( |
|
168 | - sprintf( |
|
169 | - /* |
|
25 | + private CapabilitiesCheckerInterface $capabilities_checker; |
|
26 | + |
|
27 | + private JsonDataNodeHandler $data_node_handler; |
|
28 | + |
|
29 | + private LoaderInterface $loader; |
|
30 | + |
|
31 | + protected RequestInterface $request; |
|
32 | + |
|
33 | + private RouteCollection $routes; |
|
34 | + |
|
35 | + private bool $print_data_nodes = true; |
|
36 | + |
|
37 | + protected string $route_request_type = ''; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * RouteHandler constructor. |
|
42 | + * |
|
43 | + * @param CapabilitiesCheckerInterface $capabilities_checker |
|
44 | + * @param JsonDataNodeHandler $data_node_handler |
|
45 | + * @param LoaderInterface $loader |
|
46 | + * @param RequestInterface $request |
|
47 | + * @param RouteCollection $routes |
|
48 | + */ |
|
49 | + public function __construct( |
|
50 | + CapabilitiesCheckerInterface $capabilities_checker, |
|
51 | + JsonDataNodeHandler $data_node_handler, |
|
52 | + LoaderInterface $loader, |
|
53 | + RequestInterface $request, |
|
54 | + RouteCollection $routes |
|
55 | + ) { |
|
56 | + $this->capabilities_checker = $capabilities_checker; |
|
57 | + $this->data_node_handler = $data_node_handler; |
|
58 | + $this->loader = $loader; |
|
59 | + $this->request = $request; |
|
60 | + $this->routes = $routes; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @param string $fqcn Fully Qualified Class Name for Route |
|
66 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() after adding |
|
67 | + * @throws Exception|Throwable |
|
68 | + */ |
|
69 | + public function addRoute(string $fqcn, bool $handle = true) |
|
70 | + { |
|
71 | + try { |
|
72 | + $route = $this->loader->getShared($fqcn); |
|
73 | + $this->validateRoute($route, $fqcn); |
|
74 | + if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) { |
|
75 | + $this->routes->add($route); |
|
76 | + $this->handle($route, $handle); |
|
77 | + } |
|
78 | + } catch (Exception $exception) { |
|
79 | + new ExceptionStackTraceDisplay( |
|
80 | + new DomainException( |
|
81 | + sprintf( |
|
82 | + esc_html__( |
|
83 | + 'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s', |
|
84 | + 'event_espresso' |
|
85 | + ), |
|
86 | + $fqcn, |
|
87 | + '<br />', |
|
88 | + $exception->getMessage() |
|
89 | + ) |
|
90 | + ) |
|
91 | + ); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function getRouteRequestType(): string |
|
100 | + { |
|
101 | + return $this->route_request_type; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @param string $route_request_type |
|
107 | + */ |
|
108 | + public function setRouteRequestType(string $route_request_type = '') |
|
109 | + { |
|
110 | + $this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param RouteInterface $route |
|
116 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
117 | + */ |
|
118 | + public function handle(RouteInterface $route, bool $handle = true) |
|
119 | + { |
|
120 | + if ($handle && $route->isNotHandled()) { |
|
121 | + $route->handleRequest(); |
|
122 | + if ($route instanceof PrimaryRoute) { |
|
123 | + $this->setRouteRequestType($route->getRouteRequestType()); |
|
124 | + } |
|
125 | + $data_node = $route->dataNode(); |
|
126 | + if ($data_node instanceof JsonDataNode) { |
|
127 | + $this->data_node_handler->addDataNode($data_node); |
|
128 | + $this->printDataNodes(); |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * calls RouteInterface::handleRequest() on all Routes that |
|
136 | + * - match current request |
|
137 | + * - have yet to be handled |
|
138 | + * |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + public function handleRoutesForCurrentRequest() |
|
142 | + { |
|
143 | + $this->routes->handleRoutesForCurrentRequest(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @return void |
|
149 | + */ |
|
150 | + private function printDataNodes() |
|
151 | + { |
|
152 | + if ($this->print_data_nodes) { |
|
153 | + add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
154 | + add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0); |
|
155 | + $this->print_data_nodes = false; |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * @param RouteInterface|null $route |
|
162 | + * @param string $fqcn |
|
163 | + */ |
|
164 | + private function validateRoute(?RouteInterface $route, string $fqcn = '') |
|
165 | + { |
|
166 | + if (! $route instanceof RouteInterface) { |
|
167 | + throw new InvalidClassException( |
|
168 | + sprintf( |
|
169 | + /* |
|
170 | 170 | * translators: |
171 | 171 | * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface. |
172 | 172 | */ |
173 | - esc_html__( |
|
174 | - 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
175 | - 'event_espresso' |
|
176 | - ), |
|
177 | - $fqcn |
|
178 | - ) |
|
179 | - ); |
|
180 | - } |
|
181 | - } |
|
173 | + esc_html__( |
|
174 | + 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
175 | + 'event_espresso' |
|
176 | + ), |
|
177 | + $fqcn |
|
178 | + ) |
|
179 | + ); |
|
180 | + } |
|
181 | + } |
|
182 | 182 | } |
@@ -14,63 +14,63 @@ |
||
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 | } |
@@ -39,7 +39,7 @@ |
||
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; |
@@ -17,94 +17,94 @@ |
||
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 | } |
@@ -63,7 +63,7 @@ |
||
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 | } |
@@ -15,26 +15,26 @@ |
||
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 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | $route_details = [ |
46 | 46 | 'route' => 'registrations_report', |
47 | - 'extra_request' => [ 'return_url' => $return_url ], |
|
47 | + 'extra_request' => ['return_url' => $return_url], |
|
48 | 48 | 'btn_class' => 'button button--primary', |
49 | 49 | ]; |
50 | - if (! empty($EVT_ID)) { |
|
50 | + if ( ! empty($EVT_ID)) { |
|
51 | 51 | $route_details['extra_request']['EVT_ID'] = $EVT_ID; |
52 | 52 | } |
53 | 53 | if ($DTT_ID) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | <span class="csv-report-notice__wrapper"> |
77 | 77 | <span class="dashicons dashicons-info"></span> |
78 | 78 | <span class="csv-report-notice__text"> |
79 | - ' . esc_html('All Registration CSV Reports are now triggered by the preceding button') . ' |
|
79 | + ' . esc_html('All Registration CSV Reports are now triggered by the preceding button').' |
|
80 | 80 | </span> |
81 | 81 | </span>'; |
82 | 82 | } |
@@ -13,83 +13,83 @@ |
||
13 | 13 | */ |
14 | 14 | class RegistrationsCsvReportParams |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $return_url |
|
18 | - * @param array $request_params |
|
19 | - * @param int $EVT_ID |
|
20 | - * @param int $DTT_ID |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - public static function getRequestParams( |
|
24 | - string $return_url, |
|
25 | - array $request_params = [], |
|
26 | - int $EVT_ID = 0, |
|
27 | - int $DTT_ID = 0 |
|
28 | - ): array { |
|
29 | - if ( |
|
30 | - ! EE_Capabilities::instance()->current_user_can( |
|
31 | - 'ee_read_registrations', |
|
32 | - 'espresso_registrations_registrations_reports', |
|
33 | - $EVT_ID |
|
34 | - ) |
|
35 | - ) { |
|
36 | - return []; |
|
37 | - } |
|
38 | - unset($request_params['_wp_http_referer']); |
|
39 | - add_action( |
|
40 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
41 | - [RegistrationsCsvReportParams::class, 'csvReportNotice'] |
|
42 | - ); |
|
16 | + /** |
|
17 | + * @param string $return_url |
|
18 | + * @param array $request_params |
|
19 | + * @param int $EVT_ID |
|
20 | + * @param int $DTT_ID |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + public static function getRequestParams( |
|
24 | + string $return_url, |
|
25 | + array $request_params = [], |
|
26 | + int $EVT_ID = 0, |
|
27 | + int $DTT_ID = 0 |
|
28 | + ): array { |
|
29 | + if ( |
|
30 | + ! EE_Capabilities::instance()->current_user_can( |
|
31 | + 'ee_read_registrations', |
|
32 | + 'espresso_registrations_registrations_reports', |
|
33 | + $EVT_ID |
|
34 | + ) |
|
35 | + ) { |
|
36 | + return []; |
|
37 | + } |
|
38 | + unset($request_params['_wp_http_referer']); |
|
39 | + add_action( |
|
40 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
41 | + [RegistrationsCsvReportParams::class, 'csvReportNotice'] |
|
42 | + ); |
|
43 | 43 | |
44 | - $route_details = [ |
|
45 | - 'route' => 'registrations_report', |
|
46 | - 'extra_request' => [ 'return_url' => $return_url ], |
|
47 | - 'btn_class' => 'button button--primary', |
|
48 | - ]; |
|
49 | - if (! empty($EVT_ID)) { |
|
50 | - $route_details['extra_request']['EVT_ID'] = $EVT_ID; |
|
51 | - } |
|
52 | - if ($DTT_ID) { |
|
53 | - $route_details['extra_request']['DTT_ID'] = $DTT_ID; |
|
54 | - } |
|
55 | - // detect views (status) or searches (s) and set "use_filters" to true |
|
56 | - if ( |
|
57 | - isset($request_params['_reg_status']) |
|
58 | - || isset($request_params['datetime_id']) |
|
59 | - || isset($request_params['event_id']) |
|
60 | - || isset($request_params['s']) |
|
61 | - || isset($request_params['status']) |
|
62 | - || isset($request_params['ticket_id']) |
|
63 | - ) { |
|
64 | - $request_params['use_filters'] = true; |
|
65 | - $route_details['extra_request']['use_filters'] = true; |
|
66 | - } |
|
67 | - if ( |
|
68 | - isset($request_params['use_filters']) |
|
69 | - && filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN) |
|
70 | - ) { |
|
71 | - $route_details['extra_request']['filters'] = array_diff_key( |
|
72 | - $request_params, |
|
73 | - [ |
|
74 | - 'page' => '', |
|
75 | - 'action' => '', |
|
76 | - 'default_nonce' => '', |
|
77 | - ] |
|
78 | - ); |
|
79 | - unset($route_details['extra_request']['filters']['use_filters']); |
|
80 | - } |
|
81 | - return $route_details; |
|
82 | - } |
|
44 | + $route_details = [ |
|
45 | + 'route' => 'registrations_report', |
|
46 | + 'extra_request' => [ 'return_url' => $return_url ], |
|
47 | + 'btn_class' => 'button button--primary', |
|
48 | + ]; |
|
49 | + if (! empty($EVT_ID)) { |
|
50 | + $route_details['extra_request']['EVT_ID'] = $EVT_ID; |
|
51 | + } |
|
52 | + if ($DTT_ID) { |
|
53 | + $route_details['extra_request']['DTT_ID'] = $DTT_ID; |
|
54 | + } |
|
55 | + // detect views (status) or searches (s) and set "use_filters" to true |
|
56 | + if ( |
|
57 | + isset($request_params['_reg_status']) |
|
58 | + || isset($request_params['datetime_id']) |
|
59 | + || isset($request_params['event_id']) |
|
60 | + || isset($request_params['s']) |
|
61 | + || isset($request_params['status']) |
|
62 | + || isset($request_params['ticket_id']) |
|
63 | + ) { |
|
64 | + $request_params['use_filters'] = true; |
|
65 | + $route_details['extra_request']['use_filters'] = true; |
|
66 | + } |
|
67 | + if ( |
|
68 | + isset($request_params['use_filters']) |
|
69 | + && filter_var($request_params['use_filters'], FILTER_VALIDATE_BOOLEAN) |
|
70 | + ) { |
|
71 | + $route_details['extra_request']['filters'] = array_diff_key( |
|
72 | + $request_params, |
|
73 | + [ |
|
74 | + 'page' => '', |
|
75 | + 'action' => '', |
|
76 | + 'default_nonce' => '', |
|
77 | + ] |
|
78 | + ); |
|
79 | + unset($route_details['extra_request']['filters']['use_filters']); |
|
80 | + } |
|
81 | + return $route_details; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - public static function csvReportNotice() |
|
86 | - { |
|
87 | - echo ' |
|
85 | + public static function csvReportNotice() |
|
86 | + { |
|
87 | + echo ' |
|
88 | 88 | <span class="csv-report-notice__wrapper"> |
89 | 89 | <span class="dashicons dashicons-info"></span> |
90 | 90 | <span class="csv-report-notice__text"> |
91 | 91 | ' . esc_html('All Registration CSV Reports are now triggered by the preceding button') . ' |
92 | 92 | </span> |
93 | 93 | </span>'; |
94 | - } |
|
94 | + } |
|
95 | 95 | } |
@@ -26,9 +26,9 @@ |
||
26 | 26 | <form method="POST" action="" class="mt-settings-form"> |
27 | 27 | <?php echo wp_kses($template_form_fields, AllowedTags::getWithFormTags()); ?> |
28 | 28 | <?php |
29 | - foreach ($hidden_fields as $name => $field) { |
|
30 | - echo wp_kses($field['field'], AllowedTags::getWithFormTags()); |
|
31 | - } ?> |
|
29 | + foreach ($hidden_fields as $name => $field) { |
|
30 | + echo wp_kses($field['field'], AllowedTags::getWithFormTags()); |
|
31 | + } ?> |
|
32 | 32 | <input type="submit" |
33 | 33 | value="<?php esc_attr_e('Submit', 'event_espresso'); ?>" |
34 | 34 | class="button button--secondary button--small no-drag" |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | |
15 | 15 | <h2 class="ee-admin-settings-hdr"> |
16 | 16 | <?php |
17 | - echo esc_html__('Countries and States/Provinces', 'event_espresso'); |
|
18 | - echo EEH_Template::get_help_tab_link('country_select_info'); // already escaped |
|
19 | - ?> |
|
17 | + echo esc_html__('Countries and States/Provinces', 'event_espresso'); |
|
18 | + echo EEH_Template::get_help_tab_link('country_select_info'); // already escaped |
|
19 | + ?> |
|
20 | 20 | </h2> |
21 | 21 | <table class="ee-admin-two-column-layout form-table"> |
22 | 22 | <tbody> |
@@ -26,28 +26,28 @@ discard block |
||
26 | 26 | <br/> |
27 | 27 | <p> |
28 | 28 | <?php esc_html_e( |
29 | - 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
30 | - 'event_espresso' |
|
31 | - ); ?> |
|
29 | + 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
30 | + 'event_espresso' |
|
31 | + ); ?> |
|
32 | 32 | </p> |
33 | 33 | <p id="country-currency-setting-disabled-pg" style="display: none;"> |
34 | 34 | <span class="reminder-spn"> |
35 | 35 | <?php printf( |
36 | - esc_html__( |
|
37 | - 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - $CNT_name_for_site |
|
41 | - ); ?> |
|
36 | + esc_html__( |
|
37 | + 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + $CNT_name_for_site |
|
41 | + ); ?> |
|
42 | 42 | </span> |
43 | 43 | </p> |
44 | 44 | <div id="country-settings-dv" class="ee-layout-row"> |
45 | 45 | <div id="country-details-settings-dv"> |
46 | 46 | <h2 class="ee-admin-settings-hdr"> |
47 | 47 | <?php |
48 | - echo esc_html__('Country Details', 'event_espresso'); |
|
49 | - echo wp_kses(EEH_Template::get_help_tab_link('country_details_info'), AllowedTags::getAllowedTags()); |
|
50 | - ?> |
|
48 | + echo esc_html__('Country Details', 'event_espresso'); |
|
49 | + echo wp_kses(EEH_Template::get_help_tab_link('country_details_info'), AllowedTags::getAllowedTags()); |
|
50 | + ?> |
|
51 | 51 | </h2> |
52 | 52 | <div id="country-details-dv"> |
53 | 53 | <?php echo wp_kses($country_details_settings, AllowedTags::getAllowedTags()); ?> |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | <div id="country-states-settings-dv"> |
58 | 58 | <h2 class="ee-admin-settings-hdr"> |
59 | 59 | <?php |
60 | - echo esc_html__('States/Provinces', 'event_espresso'); |
|
61 | - echo wp_kses(EEH_Template::get_help_tab_link('country_states_info'), AllowedTags::getAllowedTags()); |
|
62 | - ?> |
|
60 | + echo esc_html__('States/Provinces', 'event_espresso'); |
|
61 | + echo wp_kses(EEH_Template::get_help_tab_link('country_states_info'), AllowedTags::getAllowedTags()); |
|
62 | + ?> |
|
63 | 63 | </h2> |
64 | 64 | <div id="country-states-dv"> |
65 | 65 | <?php echo wp_kses($country_states_settings, AllowedTags::getAllowedTags()); ?> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct(EEM_Event $event_model) |
33 | 33 | { |
34 | - $this->setName($this->namespace . 'Event'); |
|
34 | + $this->setName($this->namespace.'Event'); |
|
35 | 35 | $this->setIsCustomPostType(true); |
36 | 36 | parent::__construct($event_model); |
37 | 37 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | ), |
84 | 84 | new GraphQLField( |
85 | 85 | 'defaultRegStatus', |
86 | - $this->namespace . 'RegistrationStatusEnum', |
|
86 | + $this->namespace.'RegistrationStatusEnum', |
|
87 | 87 | 'default_registration_status', |
88 | 88 | esc_html__('Default Event Registration Status', 'event_espresso') |
89 | 89 | ), |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | null, |
217 | 217 | esc_html__('Event venue ID', 'event_espresso'), |
218 | 218 | null, |
219 | - function (EE_Event $source) { |
|
219 | + function(EE_Event $source) { |
|
220 | 220 | $venue_ID = $source->venue_ID(); |
221 | 221 | return $venue_ID |
222 | 222 | // Since venue is a CPT, $type will be 'post' |
@@ -24,219 +24,219 @@ |
||
24 | 24 | */ |
25 | 25 | class Event extends TypeBase |
26 | 26 | { |
27 | - /** |
|
28 | - * Event constructor. |
|
29 | - * |
|
30 | - * @param EEM_Event $event_model |
|
31 | - */ |
|
32 | - public function __construct(EEM_Event $event_model) |
|
33 | - { |
|
34 | - $this->setName($this->namespace . 'Event'); |
|
35 | - $this->setIsCustomPostType(true); |
|
36 | - parent::__construct($event_model); |
|
37 | - } |
|
27 | + /** |
|
28 | + * Event constructor. |
|
29 | + * |
|
30 | + * @param EEM_Event $event_model |
|
31 | + */ |
|
32 | + public function __construct(EEM_Event $event_model) |
|
33 | + { |
|
34 | + $this->setName($this->namespace . 'Event'); |
|
35 | + $this->setIsCustomPostType(true); |
|
36 | + parent::__construct($event_model); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return GraphQLFieldInterface[] |
|
42 | - */ |
|
43 | - public function getFields(): array |
|
44 | - { |
|
45 | - return apply_filters( |
|
46 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__event_fields', |
|
47 | - [ |
|
48 | - new GraphQLField( |
|
49 | - 'allowDonations', |
|
50 | - 'Boolean', |
|
51 | - 'donations', |
|
52 | - esc_html__('Accept Donations?', 'event_espresso') |
|
53 | - ), |
|
54 | - new GraphQLField( |
|
55 | - 'allowOverflow', |
|
56 | - 'Boolean', |
|
57 | - 'allow_overflow', |
|
58 | - esc_html__('Enable Wait List for Event', 'event_espresso') |
|
59 | - ), |
|
60 | - new GraphQLField( |
|
61 | - 'altRegPage', |
|
62 | - 'String', |
|
63 | - 'external_url', |
|
64 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
65 | - ), |
|
66 | - new GraphQLOutputField( |
|
67 | - 'cacheId', |
|
68 | - ['non_null' => 'String'], |
|
69 | - null, |
|
70 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
71 | - ), |
|
72 | - new GraphQLField( |
|
73 | - 'created', |
|
74 | - 'String', |
|
75 | - 'created', |
|
76 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
77 | - ), |
|
78 | - new GraphQLOutputField( |
|
79 | - 'dbId', |
|
80 | - ['non_null' => 'Int'], |
|
81 | - 'ID', |
|
82 | - esc_html__('The event ID.', 'event_espresso') |
|
83 | - ), |
|
84 | - new GraphQLField( |
|
85 | - 'defaultRegStatus', |
|
86 | - $this->namespace . 'RegistrationStatusEnum', |
|
87 | - 'default_registration_status', |
|
88 | - esc_html__('Default Event Registration Status', 'event_espresso') |
|
89 | - ), |
|
90 | - new GraphQLField( |
|
91 | - 'description', |
|
92 | - 'String', |
|
93 | - 'description', |
|
94 | - esc_html__('Event Description', 'event_espresso') |
|
95 | - ), |
|
96 | - new GraphQLField( |
|
97 | - 'displayDescription', |
|
98 | - 'Boolean', |
|
99 | - 'display_description', |
|
100 | - esc_html__('Display Description Flag', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLField( |
|
103 | - 'displayTicketSelector', |
|
104 | - 'Boolean', |
|
105 | - 'display_ticket_selector', |
|
106 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLOutputField( |
|
109 | - 'isActive', |
|
110 | - 'Boolean', |
|
111 | - 'is_active', |
|
112 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
113 | - ), |
|
114 | - new GraphQLOutputField( |
|
115 | - 'isCancelled', |
|
116 | - 'Boolean', |
|
117 | - 'is_cancelled', |
|
118 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
119 | - ), |
|
120 | - new GraphQLOutputField( |
|
121 | - 'isExpired', |
|
122 | - 'Boolean', |
|
123 | - 'is_expired', |
|
124 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
125 | - ), |
|
126 | - new GraphQLOutputField( |
|
127 | - 'isInactive', |
|
128 | - 'Boolean', |
|
129 | - 'is_inactive', |
|
130 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLOutputField( |
|
133 | - 'isPostponed', |
|
134 | - 'Boolean', |
|
135 | - 'is_postponed', |
|
136 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
137 | - ), |
|
138 | - new GraphQLOutputField( |
|
139 | - 'isSoldOut', |
|
140 | - 'Boolean', |
|
141 | - 'is_sold_out', |
|
142 | - esc_html__( |
|
143 | - 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
144 | - 'event_espresso' |
|
145 | - ) |
|
146 | - ), |
|
147 | - new GraphQLOutputField( |
|
148 | - 'isUpcoming', |
|
149 | - 'Boolean', |
|
150 | - 'is_upcoming', |
|
151 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLInputField( |
|
154 | - 'manager', |
|
155 | - 'String', |
|
156 | - null, |
|
157 | - esc_html__('Globally unique event ID for the event manager', 'event_espresso') |
|
158 | - ), |
|
159 | - new GraphQLOutputField( |
|
160 | - 'manager', |
|
161 | - 'User', |
|
162 | - null, |
|
163 | - esc_html__('Event Manager', 'event_espresso') |
|
164 | - ), |
|
165 | - new GraphQLField( |
|
166 | - 'maxRegistrations', |
|
167 | - 'Int', |
|
168 | - 'additional_limit', |
|
169 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
170 | - ), |
|
171 | - new GraphQLField( |
|
172 | - 'memberOnly', |
|
173 | - 'Boolean', |
|
174 | - 'member_only', |
|
175 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
176 | - ), |
|
177 | - new GraphQLField( |
|
178 | - 'name', |
|
179 | - 'String', |
|
180 | - 'name', |
|
181 | - esc_html__('Event Name', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLField( |
|
184 | - 'order', |
|
185 | - 'Int', |
|
186 | - 'order', |
|
187 | - esc_html__('Event Menu Order', 'event_espresso') |
|
188 | - ), |
|
189 | - new GraphQLField( |
|
190 | - 'phoneNumber', |
|
191 | - 'String', |
|
192 | - 'phone', |
|
193 | - esc_html__('Event Phone Number', 'event_espresso') |
|
194 | - ), |
|
195 | - new GraphQLField( |
|
196 | - 'shortDescription', |
|
197 | - 'String', |
|
198 | - 'short_description', |
|
199 | - esc_html__('Event Short Description', 'event_espresso') |
|
200 | - ), |
|
201 | - new GraphQLField( |
|
202 | - 'timezoneString', |
|
203 | - 'String', |
|
204 | - 'timezone_string', |
|
205 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLField( |
|
208 | - 'venue', |
|
209 | - 'String', |
|
210 | - null, |
|
211 | - esc_html__('Event venue ID', 'event_espresso'), |
|
212 | - null, |
|
213 | - function (EE_Event $source) { |
|
214 | - $venue_ID = $source->venue_ID(); |
|
215 | - return $venue_ID |
|
216 | - // Since venue is a CPT, $type will be 'post' |
|
217 | - ? Relay::toGlobalId('post', $venue_ID) |
|
218 | - : null; |
|
219 | - } |
|
220 | - ), |
|
221 | - ], |
|
222 | - $this->name, |
|
223 | - $this->model |
|
224 | - ); |
|
225 | - } |
|
40 | + /** |
|
41 | + * @return GraphQLFieldInterface[] |
|
42 | + */ |
|
43 | + public function getFields(): array |
|
44 | + { |
|
45 | + return apply_filters( |
|
46 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__event_fields', |
|
47 | + [ |
|
48 | + new GraphQLField( |
|
49 | + 'allowDonations', |
|
50 | + 'Boolean', |
|
51 | + 'donations', |
|
52 | + esc_html__('Accept Donations?', 'event_espresso') |
|
53 | + ), |
|
54 | + new GraphQLField( |
|
55 | + 'allowOverflow', |
|
56 | + 'Boolean', |
|
57 | + 'allow_overflow', |
|
58 | + esc_html__('Enable Wait List for Event', 'event_espresso') |
|
59 | + ), |
|
60 | + new GraphQLField( |
|
61 | + 'altRegPage', |
|
62 | + 'String', |
|
63 | + 'external_url', |
|
64 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
65 | + ), |
|
66 | + new GraphQLOutputField( |
|
67 | + 'cacheId', |
|
68 | + ['non_null' => 'String'], |
|
69 | + null, |
|
70 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
71 | + ), |
|
72 | + new GraphQLField( |
|
73 | + 'created', |
|
74 | + 'String', |
|
75 | + 'created', |
|
76 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
77 | + ), |
|
78 | + new GraphQLOutputField( |
|
79 | + 'dbId', |
|
80 | + ['non_null' => 'Int'], |
|
81 | + 'ID', |
|
82 | + esc_html__('The event ID.', 'event_espresso') |
|
83 | + ), |
|
84 | + new GraphQLField( |
|
85 | + 'defaultRegStatus', |
|
86 | + $this->namespace . 'RegistrationStatusEnum', |
|
87 | + 'default_registration_status', |
|
88 | + esc_html__('Default Event Registration Status', 'event_espresso') |
|
89 | + ), |
|
90 | + new GraphQLField( |
|
91 | + 'description', |
|
92 | + 'String', |
|
93 | + 'description', |
|
94 | + esc_html__('Event Description', 'event_espresso') |
|
95 | + ), |
|
96 | + new GraphQLField( |
|
97 | + 'displayDescription', |
|
98 | + 'Boolean', |
|
99 | + 'display_description', |
|
100 | + esc_html__('Display Description Flag', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLField( |
|
103 | + 'displayTicketSelector', |
|
104 | + 'Boolean', |
|
105 | + 'display_ticket_selector', |
|
106 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLOutputField( |
|
109 | + 'isActive', |
|
110 | + 'Boolean', |
|
111 | + 'is_active', |
|
112 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
113 | + ), |
|
114 | + new GraphQLOutputField( |
|
115 | + 'isCancelled', |
|
116 | + 'Boolean', |
|
117 | + 'is_cancelled', |
|
118 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
119 | + ), |
|
120 | + new GraphQLOutputField( |
|
121 | + 'isExpired', |
|
122 | + 'Boolean', |
|
123 | + 'is_expired', |
|
124 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
125 | + ), |
|
126 | + new GraphQLOutputField( |
|
127 | + 'isInactive', |
|
128 | + 'Boolean', |
|
129 | + 'is_inactive', |
|
130 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLOutputField( |
|
133 | + 'isPostponed', |
|
134 | + 'Boolean', |
|
135 | + 'is_postponed', |
|
136 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
137 | + ), |
|
138 | + new GraphQLOutputField( |
|
139 | + 'isSoldOut', |
|
140 | + 'Boolean', |
|
141 | + 'is_sold_out', |
|
142 | + esc_html__( |
|
143 | + 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
144 | + 'event_espresso' |
|
145 | + ) |
|
146 | + ), |
|
147 | + new GraphQLOutputField( |
|
148 | + 'isUpcoming', |
|
149 | + 'Boolean', |
|
150 | + 'is_upcoming', |
|
151 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLInputField( |
|
154 | + 'manager', |
|
155 | + 'String', |
|
156 | + null, |
|
157 | + esc_html__('Globally unique event ID for the event manager', 'event_espresso') |
|
158 | + ), |
|
159 | + new GraphQLOutputField( |
|
160 | + 'manager', |
|
161 | + 'User', |
|
162 | + null, |
|
163 | + esc_html__('Event Manager', 'event_espresso') |
|
164 | + ), |
|
165 | + new GraphQLField( |
|
166 | + 'maxRegistrations', |
|
167 | + 'Int', |
|
168 | + 'additional_limit', |
|
169 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
170 | + ), |
|
171 | + new GraphQLField( |
|
172 | + 'memberOnly', |
|
173 | + 'Boolean', |
|
174 | + 'member_only', |
|
175 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
176 | + ), |
|
177 | + new GraphQLField( |
|
178 | + 'name', |
|
179 | + 'String', |
|
180 | + 'name', |
|
181 | + esc_html__('Event Name', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLField( |
|
184 | + 'order', |
|
185 | + 'Int', |
|
186 | + 'order', |
|
187 | + esc_html__('Event Menu Order', 'event_espresso') |
|
188 | + ), |
|
189 | + new GraphQLField( |
|
190 | + 'phoneNumber', |
|
191 | + 'String', |
|
192 | + 'phone', |
|
193 | + esc_html__('Event Phone Number', 'event_espresso') |
|
194 | + ), |
|
195 | + new GraphQLField( |
|
196 | + 'shortDescription', |
|
197 | + 'String', |
|
198 | + 'short_description', |
|
199 | + esc_html__('Event Short Description', 'event_espresso') |
|
200 | + ), |
|
201 | + new GraphQLField( |
|
202 | + 'timezoneString', |
|
203 | + 'String', |
|
204 | + 'timezone_string', |
|
205 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLField( |
|
208 | + 'venue', |
|
209 | + 'String', |
|
210 | + null, |
|
211 | + esc_html__('Event venue ID', 'event_espresso'), |
|
212 | + null, |
|
213 | + function (EE_Event $source) { |
|
214 | + $venue_ID = $source->venue_ID(); |
|
215 | + return $venue_ID |
|
216 | + // Since venue is a CPT, $type will be 'post' |
|
217 | + ? Relay::toGlobalId('post', $venue_ID) |
|
218 | + : null; |
|
219 | + } |
|
220 | + ), |
|
221 | + ], |
|
222 | + $this->name, |
|
223 | + $this->model |
|
224 | + ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Extends the existing WP GraphQL mutations. |
|
230 | - * |
|
231 | - * @since 5.0.0.p |
|
232 | - */ |
|
233 | - public function extendMutations() |
|
234 | - { |
|
235 | - add_action( |
|
236 | - 'graphql_post_object_mutation_update_additional_data', |
|
237 | - EventUpdate::mutateFields($this->model, $this), |
|
238 | - 10, |
|
239 | - 6 |
|
240 | - ); |
|
241 | - } |
|
228 | + /** |
|
229 | + * Extends the existing WP GraphQL mutations. |
|
230 | + * |
|
231 | + * @since 5.0.0.p |
|
232 | + */ |
|
233 | + public function extendMutations() |
|
234 | + { |
|
235 | + add_action( |
|
236 | + 'graphql_post_object_mutation_update_additional_data', |
|
237 | + EventUpdate::mutateFields($this->model, $this), |
|
238 | + 10, |
|
239 | + 6 |
|
240 | + ); |
|
241 | + } |
|
242 | 242 | } |