@@ -14,17 +14,17 @@ |
||
14 | 14 | */ |
15 | 15 | class WordPressPageEditorAddNew extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'post-new.php' |
|
28 | - && $this->request->getRequestParam('post_type', 'post') === 'page'; |
|
29 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'post-new.php' |
|
28 | + && $this->request->getRequestParam('post_type', 'post') === 'page'; |
|
29 | + } |
|
30 | 30 | } |
@@ -14,18 +14,18 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoAttendeePostTypeEditor extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - global $pagenow; |
|
26 | - return $pagenow |
|
27 | - && $pagenow === 'admin.php' |
|
28 | - && $this->request->getRequestParam('page') === 'espresso_registrations' |
|
29 | - && $this->request->getRequestParam('action') === 'edit_attendee'; |
|
30 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + global $pagenow; |
|
26 | + return $pagenow |
|
27 | + && $pagenow === 'admin.php' |
|
28 | + && $this->request->getRequestParam('page') === 'espresso_registrations' |
|
29 | + && $this->request->getRequestParam('action') === 'edit_attendee'; |
|
30 | + } |
|
31 | 31 | } |
@@ -15,17 +15,17 @@ |
||
15 | 15 | */ |
16 | 16 | class WordPressPostsEditorAddNew extends RouteMatchSpecification |
17 | 17 | { |
18 | - /** |
|
19 | - * returns true if current request matches specification |
|
20 | - * |
|
21 | - * @since 4.9.71.p |
|
22 | - * @return boolean |
|
23 | - */ |
|
24 | - public function isMatchingRoute() |
|
25 | - { |
|
26 | - global $pagenow; |
|
27 | - return $pagenow |
|
28 | - && $pagenow === 'post-new.php' |
|
29 | - && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
30 | - } |
|
18 | + /** |
|
19 | + * returns true if current request matches specification |
|
20 | + * |
|
21 | + * @since 4.9.71.p |
|
22 | + * @return boolean |
|
23 | + */ |
|
24 | + public function isMatchingRoute() |
|
25 | + { |
|
26 | + global $pagenow; |
|
27 | + return $pagenow |
|
28 | + && $pagenow === 'post-new.php' |
|
29 | + && $this->request->getRequestParam('post_type', 'post') === 'post'; |
|
30 | + } |
|
31 | 31 | } |
@@ -16,18 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | class WordPressPageEditorEdit extends RouteMatchSpecification |
18 | 18 | { |
19 | - /** |
|
20 | - * returns true if current request matches specification |
|
21 | - * |
|
22 | - * @since 4.9.71.p |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isMatchingRoute() |
|
26 | - { |
|
27 | - global $pagenow; |
|
28 | - return $pagenow |
|
29 | - && $pagenow === 'plugins.php' |
|
30 | - && $this->request->getRequestParam('post_type', 'post') === 'page' |
|
31 | - && $this->request->getRequestParam('action') === 'edit'; |
|
32 | - } |
|
19 | + /** |
|
20 | + * returns true if current request matches specification |
|
21 | + * |
|
22 | + * @since 4.9.71.p |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isMatchingRoute() |
|
26 | + { |
|
27 | + global $pagenow; |
|
28 | + return $pagenow |
|
29 | + && $pagenow === 'plugins.php' |
|
30 | + && $this->request->getRequestParam('post_type', 'post') === 'page' |
|
31 | + && $this->request->getRequestParam('action') === 'edit'; |
|
32 | + } |
|
33 | 33 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // @link http://josscrowcroft.github.io/accounting.js/ |
84 | 84 | $this->addJavascript( |
85 | 85 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
86 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
86 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
87 | 87 | [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
88 | 88 | true, |
89 | 89 | '0.3.2' |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->addJavascript( |
93 | 93 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
94 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
94 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
95 | 95 | [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
96 | 96 | ) |
97 | 97 | ->setInlineDataCallback( |
98 | - function () { |
|
98 | + function() { |
|
99 | 99 | wp_localize_script( |
100 | 100 | LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
101 | 101 | 'EE_ACCOUNTING_CFG', |
@@ -24,125 +24,125 @@ |
||
24 | 24 | class LegacyAccountingAssetManager extends AssetManager |
25 | 25 | { |
26 | 26 | |
27 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
28 | - |
|
29 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
30 | - |
|
31 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @var EE_Currency_Config $currency_config |
|
36 | - */ |
|
37 | - protected $currency_config; |
|
38 | - |
|
39 | - /** |
|
40 | - * CoreAssetRegister constructor. |
|
41 | - * |
|
42 | - * @param AssetCollection $assets |
|
43 | - * @param DomainInterface $domain |
|
44 | - * @param Registry $registry |
|
45 | - * @param EE_Currency_Config $currency_config |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - AssetCollection $assets, |
|
49 | - DomainInterface $domain, |
|
50 | - Registry $registry, |
|
51 | - EE_Currency_Config $currency_config |
|
52 | - ) { |
|
53 | - $this->currency_config = $currency_config; |
|
54 | - parent::__construct($domain, $assets, $registry); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @throws InvalidDataTypeException |
|
61 | - * @throws InvalidEntityException |
|
62 | - * @throws DuplicateCollectionIdentifierException |
|
63 | - * @throws DomainException |
|
64 | - */ |
|
65 | - public function addAssets() |
|
66 | - { |
|
67 | - $this->loadAccountingJs(); |
|
68 | - add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyAccountingAssets'], 100); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * accounting.js for performing client-side calculations |
|
74 | - * |
|
75 | - * @throws DomainException |
|
76 | - * @throws DuplicateCollectionIdentifierException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidEntityException |
|
79 | - * @since 5.0.0.p |
|
80 | - */ |
|
81 | - private function loadAccountingJs() |
|
82 | - { |
|
83 | - //accounting.js library |
|
84 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
85 | - $this->addJavascript( |
|
86 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
87 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
88 | - [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
|
89 | - true, |
|
90 | - '0.3.2' |
|
91 | - ); |
|
92 | - |
|
93 | - $this->addJavascript( |
|
94 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
95 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
96 | - [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
|
97 | - ) |
|
98 | - ->setInlineDataCallback( |
|
99 | - function () { |
|
100 | - wp_localize_script( |
|
101 | - LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
102 | - 'EE_ACCOUNTING_CFG', |
|
103 | - $this->getAccountingSettings() |
|
104 | - ); |
|
105 | - } |
|
106 | - ); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Returns configuration data for the accounting-js library. |
|
112 | - * |
|
113 | - * @return array |
|
114 | - * @since 5.0.0.p |
|
115 | - */ |
|
116 | - private function getAccountingSettings() |
|
117 | - { |
|
118 | - return [ |
|
119 | - 'currency' => [ |
|
120 | - 'symbol' => $this->currency_config->sign, |
|
121 | - 'format' => [ |
|
122 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
123 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
124 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
125 | - ], |
|
126 | - 'decimal' => $this->currency_config->dec_mrk, |
|
127 | - 'thousand' => $this->currency_config->thsnds, |
|
128 | - 'precision' => $this->currency_config->dec_plc, |
|
129 | - ], |
|
130 | - 'number' => [ |
|
131 | - 'precision' => $this->currency_config->dec_plc, |
|
132 | - 'thousand' => $this->currency_config->thsnds, |
|
133 | - 'decimal' => $this->currency_config->dec_mrk, |
|
134 | - ], |
|
135 | - ]; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * enqueue_scripts - Load the scripts and css |
|
141 | - * |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function enqueueLegacyAccountingAssets() |
|
145 | - { |
|
146 | - $this->enqueueAsset(LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING); |
|
147 | - } |
|
27 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
28 | + |
|
29 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
30 | + |
|
31 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @var EE_Currency_Config $currency_config |
|
36 | + */ |
|
37 | + protected $currency_config; |
|
38 | + |
|
39 | + /** |
|
40 | + * CoreAssetRegister constructor. |
|
41 | + * |
|
42 | + * @param AssetCollection $assets |
|
43 | + * @param DomainInterface $domain |
|
44 | + * @param Registry $registry |
|
45 | + * @param EE_Currency_Config $currency_config |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + AssetCollection $assets, |
|
49 | + DomainInterface $domain, |
|
50 | + Registry $registry, |
|
51 | + EE_Currency_Config $currency_config |
|
52 | + ) { |
|
53 | + $this->currency_config = $currency_config; |
|
54 | + parent::__construct($domain, $assets, $registry); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @throws InvalidDataTypeException |
|
61 | + * @throws InvalidEntityException |
|
62 | + * @throws DuplicateCollectionIdentifierException |
|
63 | + * @throws DomainException |
|
64 | + */ |
|
65 | + public function addAssets() |
|
66 | + { |
|
67 | + $this->loadAccountingJs(); |
|
68 | + add_action('admin_enqueue_scripts', [$this, 'enqueueLegacyAccountingAssets'], 100); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * accounting.js for performing client-side calculations |
|
74 | + * |
|
75 | + * @throws DomainException |
|
76 | + * @throws DuplicateCollectionIdentifierException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidEntityException |
|
79 | + * @since 5.0.0.p |
|
80 | + */ |
|
81 | + private function loadAccountingJs() |
|
82 | + { |
|
83 | + //accounting.js library |
|
84 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
85 | + $this->addJavascript( |
|
86 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
87 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
88 | + [LegacyAccountingAssetManager::JS_HANDLE_UNDERSCORE], |
|
89 | + true, |
|
90 | + '0.3.2' |
|
91 | + ); |
|
92 | + |
|
93 | + $this->addJavascript( |
|
94 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
95 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
96 | + [LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING_CORE] |
|
97 | + ) |
|
98 | + ->setInlineDataCallback( |
|
99 | + function () { |
|
100 | + wp_localize_script( |
|
101 | + LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING, |
|
102 | + 'EE_ACCOUNTING_CFG', |
|
103 | + $this->getAccountingSettings() |
|
104 | + ); |
|
105 | + } |
|
106 | + ); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Returns configuration data for the accounting-js library. |
|
112 | + * |
|
113 | + * @return array |
|
114 | + * @since 5.0.0.p |
|
115 | + */ |
|
116 | + private function getAccountingSettings() |
|
117 | + { |
|
118 | + return [ |
|
119 | + 'currency' => [ |
|
120 | + 'symbol' => $this->currency_config->sign, |
|
121 | + 'format' => [ |
|
122 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
123 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
124 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
125 | + ], |
|
126 | + 'decimal' => $this->currency_config->dec_mrk, |
|
127 | + 'thousand' => $this->currency_config->thsnds, |
|
128 | + 'precision' => $this->currency_config->dec_plc, |
|
129 | + ], |
|
130 | + 'number' => [ |
|
131 | + 'precision' => $this->currency_config->dec_plc, |
|
132 | + 'thousand' => $this->currency_config->thsnds, |
|
133 | + 'decimal' => $this->currency_config->dec_mrk, |
|
134 | + ], |
|
135 | + ]; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * enqueue_scripts - Load the scripts and css |
|
141 | + * |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function enqueueLegacyAccountingAssets() |
|
145 | + { |
|
146 | + $this->enqueueAsset(LegacyAccountingAssetManager::JS_HANDLE_ACCOUNTING); |
|
147 | + } |
|
148 | 148 | } |
@@ -16,39 +16,39 @@ |
||
16 | 16 | */ |
17 | 17 | class JsonWpOptionManager |
18 | 18 | { |
19 | - /** |
|
20 | - * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves |
|
21 | - * the object alone and returns false. |
|
22 | - * @since 4.9.80.p |
|
23 | - * @param JsonWpOptionSerializableInterface $obj |
|
24 | - * @return bool |
|
25 | - */ |
|
26 | - public function populateFromDb(JsonWpOptionSerializableInterface $obj) |
|
27 | - { |
|
28 | - $option = get_option($obj->getWpOptionName()); |
|
29 | - if ($option) { |
|
30 | - $json = json_decode($option, false); |
|
31 | - if ($json instanceof stdClass) { |
|
32 | - return $obj->fromJsonSerializedData($json); |
|
33 | - } |
|
34 | - } |
|
35 | - return false; |
|
36 | - } |
|
19 | + /** |
|
20 | + * Updates the object with what's in the DB (specifically, the wp_options table). If nothing is in the DB, leaves |
|
21 | + * the object alone and returns false. |
|
22 | + * @since 4.9.80.p |
|
23 | + * @param JsonWpOptionSerializableInterface $obj |
|
24 | + * @return bool |
|
25 | + */ |
|
26 | + public function populateFromDb(JsonWpOptionSerializableInterface $obj) |
|
27 | + { |
|
28 | + $option = get_option($obj->getWpOptionName()); |
|
29 | + if ($option) { |
|
30 | + $json = json_decode($option, false); |
|
31 | + if ($json instanceof stdClass) { |
|
32 | + return $obj->fromJsonSerializedData($json); |
|
33 | + } |
|
34 | + } |
|
35 | + return false; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Saves the object's data to the wp_options table for later use. |
|
40 | - * @since 4.9.80.p |
|
41 | - * @param JsonWpOptionSerializableInterface $obj |
|
42 | - * @return bool |
|
43 | - */ |
|
44 | - public function saveToDb(JsonWpOptionSerializableInterface $obj) |
|
45 | - { |
|
46 | - return update_option( |
|
47 | - $obj->getWpOptionName(), |
|
48 | - wp_json_encode($obj->toJsonSerializableData()), |
|
49 | - false |
|
50 | - ); |
|
51 | - } |
|
38 | + /** |
|
39 | + * Saves the object's data to the wp_options table for later use. |
|
40 | + * @since 4.9.80.p |
|
41 | + * @param JsonWpOptionSerializableInterface $obj |
|
42 | + * @return bool |
|
43 | + */ |
|
44 | + public function saveToDb(JsonWpOptionSerializableInterface $obj) |
|
45 | + { |
|
46 | + return update_option( |
|
47 | + $obj->getWpOptionName(), |
|
48 | + wp_json_encode($obj->toJsonSerializableData()), |
|
49 | + false |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | // End of file JsonWpOptionManager.php |
54 | 54 | // Location: EventEspresso\core\services\options/JsonWpOptionManager.php |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function setEditorScriptHandle($editor_script_handle) |
61 | 61 | { |
62 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
63 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | + if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
63 | + $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle; |
|
64 | 64 | } |
65 | 65 | $this->editor_script_handle = $editor_script_handle; |
66 | 66 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function setEditorStyleHandle($editor_style_handle) |
82 | 82 | { |
83 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
84 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
84 | + $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle; |
|
85 | 85 | } |
86 | 86 | $this->editor_style_handle = $editor_style_handle; |
87 | 87 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setScriptHandle($script_handle) |
103 | 103 | { |
104 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
105 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | + if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
105 | + $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle; |
|
106 | 106 | } |
107 | 107 | $this->script_handle = $script_handle; |
108 | 108 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setStyleHandle($style_handle) |
124 | 124 | { |
125 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
126 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | + if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
126 | + $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle; |
|
127 | 127 | } |
128 | 128 | $this->style_handle = $style_handle; |
129 | 129 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function addEditorScript($handle, array $dependencies = array()) |
156 | 156 | { |
157 | - if ($this->assets->hasJavascriptAsset($handle)){ |
|
157 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
158 | 158 | return $this->assets->getJavascriptAsset($handle); |
159 | 159 | } |
160 | 160 | $dependencies = array_merge( |
@@ -20,253 +20,253 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string $editor_script_handle |
|
25 | - */ |
|
26 | - private $editor_script_handle; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $editor_style_handle |
|
30 | - */ |
|
31 | - private $editor_style_handle; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $script_handle |
|
35 | - */ |
|
36 | - private $script_handle; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string $style_handle |
|
40 | - */ |
|
41 | - private $style_handle; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function getEditorScriptHandle() |
|
48 | - { |
|
49 | - return $this->editor_script_handle; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $editor_script_handle |
|
55 | - */ |
|
56 | - public function setEditorScriptHandle($editor_script_handle) |
|
57 | - { |
|
58 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
59 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | - } |
|
61 | - $this->editor_script_handle = $editor_script_handle; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getEditorStyleHandle() |
|
69 | - { |
|
70 | - return $this->editor_style_handle; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $editor_style_handle |
|
76 | - */ |
|
77 | - public function setEditorStyleHandle($editor_style_handle) |
|
78 | - { |
|
79 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
80 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | - } |
|
82 | - $this->editor_style_handle = $editor_style_handle; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function getScriptHandle() |
|
90 | - { |
|
91 | - return $this->script_handle; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @param string $script_handle |
|
97 | - */ |
|
98 | - public function setScriptHandle($script_handle) |
|
99 | - { |
|
100 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
101 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | - } |
|
103 | - $this->script_handle = $script_handle; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function getStyleHandle() |
|
111 | - { |
|
112 | - return $this->style_handle; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $style_handle |
|
118 | - */ |
|
119 | - public function setStyleHandle($style_handle) |
|
120 | - { |
|
121 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
122 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | - } |
|
124 | - $this->style_handle = $style_handle; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @since 4.9.71.p |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - * @throws InvalidEntityException |
|
131 | - * @throws DuplicateCollectionIdentifierException |
|
132 | - */ |
|
133 | - public function addAssets() |
|
134 | - { |
|
135 | - $this->addEditorScript($this->getEditorScriptHandle()); |
|
136 | - // $this->addEditorStyle($this->getEditorStyleHandle()); |
|
137 | - $this->addScript($this->getScriptHandle()); |
|
138 | - // $this->addStyle($this->getStyleHandle()); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param $handle |
|
144 | - * @param array $dependencies |
|
145 | - * @since 4.9.71.p |
|
146 | - * @return JavascriptAsset |
|
147 | - * @throws InvalidDataTypeException |
|
148 | - * @throws InvalidEntityException |
|
149 | - * @throws DuplicateCollectionIdentifierException |
|
150 | - */ |
|
151 | - public function addEditorScript($handle, array $dependencies = array()) |
|
152 | - { |
|
153 | - if ($this->assets->hasJavascriptAsset($handle)){ |
|
154 | - return $this->assets->getJavascriptAsset($handle); |
|
155 | - } |
|
156 | - $dependencies = array_merge( |
|
157 | - $dependencies, |
|
158 | - ['wp-blocks'] |
|
159 | - ); |
|
160 | - return $this->addJs($handle, $dependencies); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param $handle |
|
166 | - * @param array $dependencies |
|
167 | - * @since 4.9.71.p |
|
168 | - * @return StylesheetAsset |
|
169 | - * @throws InvalidDataTypeException |
|
170 | - * @throws InvalidEntityException |
|
171 | - * @throws DuplicateCollectionIdentifierException |
|
172 | - */ |
|
173 | - public function addEditorStyle($handle, array $dependencies = array()) |
|
174 | - { |
|
175 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
176 | - return $this->assets->getStylesheetAsset($handle); |
|
177 | - } |
|
178 | - return $this->addCss($handle, $dependencies); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @param $handle |
|
184 | - * @param array $dependencies |
|
185 | - * @since 4.9.71.p |
|
186 | - * @return JavascriptAsset |
|
187 | - * @throws InvalidDataTypeException |
|
188 | - * @throws InvalidEntityException |
|
189 | - * @throws DuplicateCollectionIdentifierException |
|
190 | - */ |
|
191 | - public function addScript($handle, array $dependencies = array()) |
|
192 | - { |
|
193 | - if ($this->assets->hasJavascriptAsset($handle)) { |
|
194 | - return $this->assets->getJavascriptAsset($handle); |
|
195 | - } |
|
196 | - return $this->addJs($handle, $dependencies); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @param $handle |
|
202 | - * @param array $dependencies |
|
203 | - * @since 4.9.71.p |
|
204 | - * @return StylesheetAsset |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidEntityException |
|
207 | - * @throws DuplicateCollectionIdentifierException |
|
208 | - */ |
|
209 | - public function addStyle($handle, array $dependencies = array()) |
|
210 | - { |
|
211 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
212 | - return $this->assets->getStylesheetAsset($handle); |
|
213 | - } |
|
214 | - return $this->addCss($handle, $dependencies); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * @return JavascriptAsset|null |
|
220 | - */ |
|
221 | - public function getEditorScript() |
|
222 | - { |
|
223 | - return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @return StylesheetAsset|null |
|
229 | - */ |
|
230 | - public function getEditorStyle() |
|
231 | - { |
|
232 | - return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * @return JavascriptAsset|null |
|
238 | - */ |
|
239 | - public function getScript() |
|
240 | - { |
|
241 | - return $this->assets->getJavascriptAsset($this->script_handle); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @return StylesheetAsset|null |
|
247 | - */ |
|
248 | - public function getStyle() |
|
249 | - { |
|
250 | - return $this->assets->getStylesheetAsset($this->style_handle); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - public function enqueueAssets() |
|
258 | - { |
|
259 | - $assets = array( |
|
260 | - $this->getEditorScript(), |
|
261 | - $this->getEditorStyle(), |
|
262 | - $this->getScript(), |
|
263 | - $this->getStyle(), |
|
264 | - ); |
|
265 | - foreach ($assets as $asset) { |
|
266 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
267 | - $asset->enqueueAsset(); |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
23 | + /** |
|
24 | + * @var string $editor_script_handle |
|
25 | + */ |
|
26 | + private $editor_script_handle; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $editor_style_handle |
|
30 | + */ |
|
31 | + private $editor_style_handle; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $script_handle |
|
35 | + */ |
|
36 | + private $script_handle; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string $style_handle |
|
40 | + */ |
|
41 | + private $style_handle; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function getEditorScriptHandle() |
|
48 | + { |
|
49 | + return $this->editor_script_handle; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $editor_script_handle |
|
55 | + */ |
|
56 | + public function setEditorScriptHandle($editor_script_handle) |
|
57 | + { |
|
58 | + if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
59 | + $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | + } |
|
61 | + $this->editor_script_handle = $editor_script_handle; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getEditorStyleHandle() |
|
69 | + { |
|
70 | + return $this->editor_style_handle; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $editor_style_handle |
|
76 | + */ |
|
77 | + public function setEditorStyleHandle($editor_style_handle) |
|
78 | + { |
|
79 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
80 | + $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | + } |
|
82 | + $this->editor_style_handle = $editor_style_handle; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function getScriptHandle() |
|
90 | + { |
|
91 | + return $this->script_handle; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @param string $script_handle |
|
97 | + */ |
|
98 | + public function setScriptHandle($script_handle) |
|
99 | + { |
|
100 | + if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
101 | + $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | + } |
|
103 | + $this->script_handle = $script_handle; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function getStyleHandle() |
|
111 | + { |
|
112 | + return $this->style_handle; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $style_handle |
|
118 | + */ |
|
119 | + public function setStyleHandle($style_handle) |
|
120 | + { |
|
121 | + if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
122 | + $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | + } |
|
124 | + $this->style_handle = $style_handle; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @since 4.9.71.p |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + * @throws InvalidEntityException |
|
131 | + * @throws DuplicateCollectionIdentifierException |
|
132 | + */ |
|
133 | + public function addAssets() |
|
134 | + { |
|
135 | + $this->addEditorScript($this->getEditorScriptHandle()); |
|
136 | + // $this->addEditorStyle($this->getEditorStyleHandle()); |
|
137 | + $this->addScript($this->getScriptHandle()); |
|
138 | + // $this->addStyle($this->getStyleHandle()); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param $handle |
|
144 | + * @param array $dependencies |
|
145 | + * @since 4.9.71.p |
|
146 | + * @return JavascriptAsset |
|
147 | + * @throws InvalidDataTypeException |
|
148 | + * @throws InvalidEntityException |
|
149 | + * @throws DuplicateCollectionIdentifierException |
|
150 | + */ |
|
151 | + public function addEditorScript($handle, array $dependencies = array()) |
|
152 | + { |
|
153 | + if ($this->assets->hasJavascriptAsset($handle)){ |
|
154 | + return $this->assets->getJavascriptAsset($handle); |
|
155 | + } |
|
156 | + $dependencies = array_merge( |
|
157 | + $dependencies, |
|
158 | + ['wp-blocks'] |
|
159 | + ); |
|
160 | + return $this->addJs($handle, $dependencies); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param $handle |
|
166 | + * @param array $dependencies |
|
167 | + * @since 4.9.71.p |
|
168 | + * @return StylesheetAsset |
|
169 | + * @throws InvalidDataTypeException |
|
170 | + * @throws InvalidEntityException |
|
171 | + * @throws DuplicateCollectionIdentifierException |
|
172 | + */ |
|
173 | + public function addEditorStyle($handle, array $dependencies = array()) |
|
174 | + { |
|
175 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
176 | + return $this->assets->getStylesheetAsset($handle); |
|
177 | + } |
|
178 | + return $this->addCss($handle, $dependencies); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @param $handle |
|
184 | + * @param array $dependencies |
|
185 | + * @since 4.9.71.p |
|
186 | + * @return JavascriptAsset |
|
187 | + * @throws InvalidDataTypeException |
|
188 | + * @throws InvalidEntityException |
|
189 | + * @throws DuplicateCollectionIdentifierException |
|
190 | + */ |
|
191 | + public function addScript($handle, array $dependencies = array()) |
|
192 | + { |
|
193 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
194 | + return $this->assets->getJavascriptAsset($handle); |
|
195 | + } |
|
196 | + return $this->addJs($handle, $dependencies); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @param $handle |
|
202 | + * @param array $dependencies |
|
203 | + * @since 4.9.71.p |
|
204 | + * @return StylesheetAsset |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidEntityException |
|
207 | + * @throws DuplicateCollectionIdentifierException |
|
208 | + */ |
|
209 | + public function addStyle($handle, array $dependencies = array()) |
|
210 | + { |
|
211 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
212 | + return $this->assets->getStylesheetAsset($handle); |
|
213 | + } |
|
214 | + return $this->addCss($handle, $dependencies); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * @return JavascriptAsset|null |
|
220 | + */ |
|
221 | + public function getEditorScript() |
|
222 | + { |
|
223 | + return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @return StylesheetAsset|null |
|
229 | + */ |
|
230 | + public function getEditorStyle() |
|
231 | + { |
|
232 | + return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * @return JavascriptAsset|null |
|
238 | + */ |
|
239 | + public function getScript() |
|
240 | + { |
|
241 | + return $this->assets->getJavascriptAsset($this->script_handle); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @return StylesheetAsset|null |
|
247 | + */ |
|
248 | + public function getStyle() |
|
249 | + { |
|
250 | + return $this->assets->getStylesheetAsset($this->style_handle); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + public function enqueueAssets() |
|
258 | + { |
|
259 | + $assets = array( |
|
260 | + $this->getEditorScript(), |
|
261 | + $this->getEditorStyle(), |
|
262 | + $this->getScript(), |
|
263 | + $this->getStyle(), |
|
264 | + ); |
|
265 | + foreach ($assets as $asset) { |
|
266 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
267 | + $asset->enqueueAsset(); |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | 272 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
74 | 74 | */ |
75 | 75 | $input_fields = []; |
76 | - if (! empty($this->args['where'])) { |
|
76 | + if ( ! empty($this->args['where'])) { |
|
77 | 77 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
78 | 78 | } |
79 | 79 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Merge the input_fields with the default query_args |
100 | 100 | */ |
101 | - if (! empty($input_fields)) { |
|
101 | + if ( ! empty($input_fields)) { |
|
102 | 102 | $where_params = array_merge($where_params, $input_fields); |
103 | 103 | } |
104 | 104 |
@@ -16,130 +16,130 @@ |
||
16 | 16 | */ |
17 | 17 | class VenueConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - public function get_loader_name(): string |
|
21 | - { |
|
22 | - return 'espresso_venue'; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return EEM_Venue |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | - public function get_query(): EEM_Venue |
|
35 | - { |
|
36 | - return EEM_Venue::instance(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Return an array of item IDs from the query |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | - public function get_ids(): array |
|
47 | - { |
|
48 | - $results = $this->query->get_col($this->query_args); |
|
49 | - |
|
50 | - return ! empty($results) ? $results : []; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | - * handle batch resolution of the posts. |
|
58 | - * |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | - public function get_query_args(): array |
|
63 | - { |
|
64 | - $where_params = []; |
|
65 | - $query_args = []; |
|
66 | - |
|
67 | - $query_args['limit'] = $this->getLimit(); |
|
68 | - |
|
69 | - // Avoid multiple entries by join. |
|
70 | - $query_args['group_by'] = 'VNU_ID'; |
|
71 | - |
|
72 | - $query_args['default_where_conditions'] = 'minimum'; |
|
73 | - |
|
74 | - /** |
|
75 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | - */ |
|
77 | - $input_fields = []; |
|
78 | - if (! empty($this->args['where'])) { |
|
79 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | - * set the query to pull datetimes that belong to that event. |
|
86 | - * We can set more cases for other source types. |
|
87 | - */ |
|
88 | - if (is_object($this->source)) { |
|
89 | - switch (true) { |
|
90 | - // Assumed to be an event |
|
91 | - case $this->source instanceof Post: |
|
92 | - $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | - break; |
|
94 | - case $this->source instanceof EE_Event: |
|
95 | - $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | - break; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Merge the input_fields with the default query_args |
|
102 | - */ |
|
103 | - if (! empty($input_fields)) { |
|
104 | - $where_params = array_merge($where_params, $input_fields); |
|
105 | - } |
|
106 | - |
|
107 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | - |
|
109 | - $where_params = apply_filters( |
|
110 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | - $where_params, |
|
112 | - $this->source, |
|
113 | - $this->args |
|
114 | - ); |
|
115 | - |
|
116 | - $query_args[] = $where_params; |
|
117 | - |
|
118 | - /** |
|
119 | - * Return the $query_args |
|
120 | - */ |
|
121 | - return apply_filters( |
|
122 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | - $query_args, |
|
124 | - $this->source, |
|
125 | - $this->args |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | - * friendly keys. |
|
133 | - * |
|
134 | - * @param array $where_args |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function sanitizeInputFields(array $where_args): array |
|
138 | - { |
|
139 | - return $this->sanitizeWhereArgsForInputFields( |
|
140 | - $where_args, |
|
141 | - [], |
|
142 | - [] |
|
143 | - ); |
|
144 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + public function get_loader_name(): string |
|
21 | + { |
|
22 | + return 'espresso_venue'; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return EEM_Venue |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | + public function get_query(): EEM_Venue |
|
35 | + { |
|
36 | + return EEM_Venue::instance(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Return an array of item IDs from the query |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | + public function get_ids(): array |
|
47 | + { |
|
48 | + $results = $this->query->get_col($this->query_args); |
|
49 | + |
|
50 | + return ! empty($results) ? $results : []; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | + * handle batch resolution of the posts. |
|
58 | + * |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | + public function get_query_args(): array |
|
63 | + { |
|
64 | + $where_params = []; |
|
65 | + $query_args = []; |
|
66 | + |
|
67 | + $query_args['limit'] = $this->getLimit(); |
|
68 | + |
|
69 | + // Avoid multiple entries by join. |
|
70 | + $query_args['group_by'] = 'VNU_ID'; |
|
71 | + |
|
72 | + $query_args['default_where_conditions'] = 'minimum'; |
|
73 | + |
|
74 | + /** |
|
75 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | + */ |
|
77 | + $input_fields = []; |
|
78 | + if (! empty($this->args['where'])) { |
|
79 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | + * set the query to pull datetimes that belong to that event. |
|
86 | + * We can set more cases for other source types. |
|
87 | + */ |
|
88 | + if (is_object($this->source)) { |
|
89 | + switch (true) { |
|
90 | + // Assumed to be an event |
|
91 | + case $this->source instanceof Post: |
|
92 | + $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | + break; |
|
94 | + case $this->source instanceof EE_Event: |
|
95 | + $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | + break; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Merge the input_fields with the default query_args |
|
102 | + */ |
|
103 | + if (! empty($input_fields)) { |
|
104 | + $where_params = array_merge($where_params, $input_fields); |
|
105 | + } |
|
106 | + |
|
107 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | + |
|
109 | + $where_params = apply_filters( |
|
110 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | + $where_params, |
|
112 | + $this->source, |
|
113 | + $this->args |
|
114 | + ); |
|
115 | + |
|
116 | + $query_args[] = $where_params; |
|
117 | + |
|
118 | + /** |
|
119 | + * Return the $query_args |
|
120 | + */ |
|
121 | + return apply_filters( |
|
122 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | + $query_args, |
|
124 | + $this->source, |
|
125 | + $this->args |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | + * friendly keys. |
|
133 | + * |
|
134 | + * @param array $where_args |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function sanitizeInputFields(array $where_args): array |
|
138 | + { |
|
139 | + return $this->sanitizeWhereArgsForInputFields( |
|
140 | + $where_args, |
|
141 | + [], |
|
142 | + [] |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | public function initialize() |
37 | 37 | { |
38 | 38 | $current_user = wp_get_current_user(); |
39 | - if (! $current_user instanceof WP_User) { |
|
39 | + if ( ! $current_user instanceof WP_User) { |
|
40 | 40 | $current_user = new WP_User(); |
41 | 41 | } |
42 | 42 |
@@ -16,51 +16,51 @@ |
||
16 | 16 | */ |
17 | 17 | class CurrentUser extends JsonDataNode |
18 | 18 | { |
19 | - const NODE_NAME = 'currentUser'; |
|
19 | + const NODE_NAME = 'currentUser'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var Capabilities $capabilities |
|
23 | - */ |
|
24 | - private $capabilities; |
|
21 | + /** |
|
22 | + * @var Capabilities $capabilities |
|
23 | + */ |
|
24 | + private $capabilities; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param Capabilities $capabilities |
|
28 | - * @param JsonDataNodeValidator $validator |
|
29 | - */ |
|
30 | - public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator) |
|
31 | - { |
|
32 | - parent::__construct($validator); |
|
33 | - $this->capabilities = $capabilities; |
|
34 | - $this->setNodeName(CurrentUser::NODE_NAME); |
|
35 | - } |
|
26 | + /** |
|
27 | + * @param Capabilities $capabilities |
|
28 | + * @param JsonDataNodeValidator $validator |
|
29 | + */ |
|
30 | + public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator) |
|
31 | + { |
|
32 | + parent::__construct($validator); |
|
33 | + $this->capabilities = $capabilities; |
|
34 | + $this->setNodeName(CurrentUser::NODE_NAME); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @inheritDoc |
|
39 | - */ |
|
40 | - public function initialize() |
|
41 | - { |
|
42 | - $current_user = wp_get_current_user(); |
|
43 | - if (! $current_user instanceof WP_User) { |
|
44 | - $current_user = new WP_User(); |
|
45 | - } |
|
37 | + /** |
|
38 | + * @inheritDoc |
|
39 | + */ |
|
40 | + public function initialize() |
|
41 | + { |
|
42 | + $current_user = wp_get_current_user(); |
|
43 | + if (! $current_user instanceof WP_User) { |
|
44 | + $current_user = new WP_User(); |
|
45 | + } |
|
46 | 46 | |
47 | - if (class_exists(Relay::class)) { |
|
48 | - $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
49 | - } |
|
50 | - $this->addData('databaseId', $current_user->ID); |
|
51 | - $this->addData('description', $current_user->description); |
|
52 | - $this->addData('email', $current_user->user_email); |
|
53 | - $this->addData('firstName', $current_user->first_name); |
|
54 | - $this->addData('isa', is_super_admin($current_user->ID)); |
|
55 | - $this->addData('lastName', $current_user->last_name); |
|
56 | - $this->addData('locale', get_user_locale($current_user->ID)); |
|
57 | - $this->addData('name', $current_user->display_name); |
|
58 | - $this->addData('nicename', $current_user->user_nicename); |
|
59 | - $this->addData('nickname', $current_user->nickname); |
|
60 | - $this->addData('username', $current_user->user_login); |
|
61 | - $this->addData('roles', $current_user->roles); |
|
62 | - $this->addData('__typename', 'User'); |
|
63 | - $this->addDataNode($this->capabilities); |
|
64 | - $this->setInitialized(true); |
|
65 | - } |
|
47 | + if (class_exists(Relay::class)) { |
|
48 | + $this->addData('id', Relay::toGlobalId('user', $current_user->ID)); |
|
49 | + } |
|
50 | + $this->addData('databaseId', $current_user->ID); |
|
51 | + $this->addData('description', $current_user->description); |
|
52 | + $this->addData('email', $current_user->user_email); |
|
53 | + $this->addData('firstName', $current_user->first_name); |
|
54 | + $this->addData('isa', is_super_admin($current_user->ID)); |
|
55 | + $this->addData('lastName', $current_user->last_name); |
|
56 | + $this->addData('locale', get_user_locale($current_user->ID)); |
|
57 | + $this->addData('name', $current_user->display_name); |
|
58 | + $this->addData('nicename', $current_user->user_nicename); |
|
59 | + $this->addData('nickname', $current_user->nickname); |
|
60 | + $this->addData('username', $current_user->user_login); |
|
61 | + $this->addData('roles', $current_user->roles); |
|
62 | + $this->addData('__typename', 'User'); |
|
63 | + $this->addDataNode($this->capabilities); |
|
64 | + $this->setInitialized(true); |
|
65 | + } |
|
66 | 66 | } |