PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.3
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.3
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / API / V2 / Proxy / Scoped_Proxy_Behavior.php

Scoped_Proxy_Behavior.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.3, at includes/API/V2/Proxy/Scoped_Proxy_Behavior.php

78 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Scoped catalog proxy behavior base.
4 *
5 * @package WCPOS\WooCommercePOS\API\V2\Proxy
6 */
7
8 namespace WCPOS\WooCommercePOS\API\V2\Proxy;
9
10 use WP_REST_Request;
11
12 /**
13 * Gives every resource the same install/run/finally/unwind discipline.
14 */
15 abstract class Scoped_Proxy_Behavior implements Proxy_Behavior {
16 /**
17 * Forward every param untouched.
18 *
19 * @param array $params Query parameters to forward.
20 * @param WP_REST_Request $request Original proxy request.
21 *
22 * @return array
23 */
24 public function forwarded_params( array $params, WP_REST_Request $request ): array {
25 return $params;
26 }
27
28 /**
29 * Install this resource's hooks, run the forward, and always unwind.
30 *
31 * @param callable $forward Forward operation.
32 *
33 * @return mixed
34 */
35 public function around( callable $forward ) {
36 $bindings = $this->install();
37
38 try {
39 return $this->run( $forward );
40 } finally {
41 foreach ( array_reverse( $bindings ) as $binding ) {
42 remove_filter( $binding[0], $binding[1], $binding[2] );
43 }
44 }
45 }
46
47 /**
48 * Return the response data unshaped.
49 *
50 * @param mixed $data Response data.
51 *
52 * @return mixed
53 */
54 public function post_process( $data ) {
55 return $data;
56 }
57
58 /**
59 * Install hooks and return their exact removal tuples.
60 *
61 * @return array<int, array{0: string, 1: callable, 2: int}>
62 */
63 protected function install(): array {
64 return array();
65 }
66
67 /**
68 * Run the forward, optionally through a resource plan.
69 *
70 * @param callable $forward Forward operation.
71 *
72 * @return mixed
73 */
74 protected function run( callable $forward ) {
75 return $forward();
76 }
77 }
78