@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
58 | 58 | ]; |
59 | 59 | $path_to_event = 'Event'; |
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
61 | 61 | $path_to_event |
62 | 62 | ); |
63 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected( |
|
64 | 64 | $path_to_event |
65 | 65 | ); |
66 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
67 | 67 | $path_to_event |
68 | 68 | ); |
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected( |
|
70 | 70 | $path_to_event, |
71 | 71 | EEM_Base::caps_edit |
72 | 72 | ); |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | $where = []; |
118 | - if (! empty($GRP_IDs)) { |
|
118 | + if ( ! empty($GRP_IDs)) { |
|
119 | 119 | $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
120 | 120 | } |
121 | - if (! empty($EVT_IDs)) { |
|
121 | + if ( ! empty($EVT_IDs)) { |
|
122 | 122 | $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
123 | 123 | } |
124 | 124 |
@@ -11,134 +11,134 @@ |
||
11 | 11 | */ |
12 | 12 | class EEM_Event_Message_Template extends EEM_Base |
13 | 13 | { |
14 | - // private instance of the EEM_Event_Message_Template object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the EEM_Event_Message_Template object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * protected constructor to prevent direct creation |
|
20 | - * |
|
21 | - * @param null $timezone |
|
22 | - * @throws EE_Error |
|
23 | - */ |
|
24 | - protected function __construct($timezone = null) |
|
25 | - { |
|
26 | - $this->singular_item = esc_html__('Event Message Template', 'event_espresso'); |
|
27 | - $this->plural_item = esc_html__('Event Message Templates', 'event_espresso'); |
|
18 | + /** |
|
19 | + * protected constructor to prevent direct creation |
|
20 | + * |
|
21 | + * @param null $timezone |
|
22 | + * @throws EE_Error |
|
23 | + */ |
|
24 | + protected function __construct($timezone = null) |
|
25 | + { |
|
26 | + $this->singular_item = esc_html__('Event Message Template', 'event_espresso'); |
|
27 | + $this->plural_item = esc_html__('Event Message Templates', 'event_espresso'); |
|
28 | 28 | |
29 | - $this->_tables = [ |
|
30 | - 'Event_Message_Template' => new EE_Primary_Table('esp_event_message_template', 'EMT_ID'), |
|
31 | - ]; |
|
32 | - $this->_fields = [ |
|
33 | - 'Event_Message_Template' => [ |
|
34 | - 'EMT_ID' => new EE_Primary_Key_Int_Field( |
|
35 | - 'EMT_ID', |
|
36 | - esc_html__('Event Message Template ID', 'event_espresso') |
|
37 | - ), |
|
38 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
39 | - 'EVT_ID', |
|
40 | - esc_html__('The ID to the Event', 'event_espresso'), |
|
41 | - false, |
|
42 | - 0, |
|
43 | - 'Event' |
|
44 | - ), |
|
45 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | - 'GRP_ID', |
|
47 | - esc_html__('The ID to the Message Template Group', 'event_espresso'), |
|
48 | - false, |
|
49 | - 0, |
|
50 | - 'Message_Template_Group' |
|
51 | - ), |
|
52 | - ], |
|
53 | - ]; |
|
54 | - $this->_model_relations = [ |
|
55 | - 'Event' => new EE_Belongs_To_Relation(), |
|
56 | - 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
57 | - ]; |
|
58 | - $path_to_event = 'Event'; |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | - $path_to_event |
|
61 | - ); |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | - $path_to_event |
|
64 | - ); |
|
65 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | - $path_to_event |
|
67 | - ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | - $path_to_event, |
|
70 | - EEM_Base::caps_edit |
|
71 | - ); |
|
72 | - parent::__construct($timezone); |
|
73 | - } |
|
29 | + $this->_tables = [ |
|
30 | + 'Event_Message_Template' => new EE_Primary_Table('esp_event_message_template', 'EMT_ID'), |
|
31 | + ]; |
|
32 | + $this->_fields = [ |
|
33 | + 'Event_Message_Template' => [ |
|
34 | + 'EMT_ID' => new EE_Primary_Key_Int_Field( |
|
35 | + 'EMT_ID', |
|
36 | + esc_html__('Event Message Template ID', 'event_espresso') |
|
37 | + ), |
|
38 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
39 | + 'EVT_ID', |
|
40 | + esc_html__('The ID to the Event', 'event_espresso'), |
|
41 | + false, |
|
42 | + 0, |
|
43 | + 'Event' |
|
44 | + ), |
|
45 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
46 | + 'GRP_ID', |
|
47 | + esc_html__('The ID to the Message Template Group', 'event_espresso'), |
|
48 | + false, |
|
49 | + 0, |
|
50 | + 'Message_Template_Group' |
|
51 | + ), |
|
52 | + ], |
|
53 | + ]; |
|
54 | + $this->_model_relations = [ |
|
55 | + 'Event' => new EE_Belongs_To_Relation(), |
|
56 | + 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
57 | + ]; |
|
58 | + $path_to_event = 'Event'; |
|
59 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( |
|
60 | + $path_to_event |
|
61 | + ); |
|
62 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
63 | + $path_to_event |
|
64 | + ); |
|
65 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
66 | + $path_to_event |
|
67 | + ); |
|
68 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( |
|
69 | + $path_to_event, |
|
70 | + EEM_Base::caps_edit |
|
71 | + ); |
|
72 | + parent::__construct($timezone); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * helper method to simply return an array of event ids for events attached to the given |
|
78 | - * message template group. |
|
79 | - * |
|
80 | - * @param int $GRP_ID The MTP group we want attached events for. |
|
81 | - * @return array An array of event ids. |
|
82 | - * @throws EE_Error |
|
83 | - * @since 4.3.0 |
|
84 | - */ |
|
85 | - public function get_attached_event_ids($GRP_ID) |
|
86 | - { |
|
87 | - $event_ids = $this->_get_all_wpdb_results([['GRP_ID' => $GRP_ID]], ARRAY_N, 'EVT_ID'); |
|
88 | - $event_ids = call_user_func_array('array_merge', $event_ids); |
|
89 | - return $event_ids; |
|
90 | - } |
|
76 | + /** |
|
77 | + * helper method to simply return an array of event ids for events attached to the given |
|
78 | + * message template group. |
|
79 | + * |
|
80 | + * @param int $GRP_ID The MTP group we want attached events for. |
|
81 | + * @return array An array of event ids. |
|
82 | + * @throws EE_Error |
|
83 | + * @since 4.3.0 |
|
84 | + */ |
|
85 | + public function get_attached_event_ids($GRP_ID) |
|
86 | + { |
|
87 | + $event_ids = $this->_get_all_wpdb_results([['GRP_ID' => $GRP_ID]], ARRAY_N, 'EVT_ID'); |
|
88 | + $event_ids = call_user_func_array('array_merge', $event_ids); |
|
89 | + return $event_ids; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * helper method for clearing event/group relations for the given event ids and grp ids. |
|
95 | - * |
|
96 | - * @param array $GRP_IDs An array of GRP_IDs. Optional. If empty then there must be EVT IDs. |
|
97 | - * @param array $EVT_IDs An array of EVT_IDs. Optional. If empty then there must be GRP IDs. |
|
98 | - * @return int How many rows were deleted. |
|
99 | - * @throws EE_Error |
|
100 | - * @throws EE_Error |
|
101 | - */ |
|
102 | - public function delete_event_group_relations($GRP_IDs = [], $EVT_IDs = []) |
|
103 | - { |
|
104 | - if (empty($GRP_IDs) && empty($EVT_IDs)) { |
|
105 | - throw new EE_Error( |
|
106 | - sprintf( |
|
107 | - esc_html__( |
|
108 | - '%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - __METHOD__ |
|
112 | - ) |
|
113 | - ); |
|
114 | - } |
|
93 | + /** |
|
94 | + * helper method for clearing event/group relations for the given event ids and grp ids. |
|
95 | + * |
|
96 | + * @param array $GRP_IDs An array of GRP_IDs. Optional. If empty then there must be EVT IDs. |
|
97 | + * @param array $EVT_IDs An array of EVT_IDs. Optional. If empty then there must be GRP IDs. |
|
98 | + * @return int How many rows were deleted. |
|
99 | + * @throws EE_Error |
|
100 | + * @throws EE_Error |
|
101 | + */ |
|
102 | + public function delete_event_group_relations($GRP_IDs = [], $EVT_IDs = []) |
|
103 | + { |
|
104 | + if (empty($GRP_IDs) && empty($EVT_IDs)) { |
|
105 | + throw new EE_Error( |
|
106 | + sprintf( |
|
107 | + esc_html__( |
|
108 | + '%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + __METHOD__ |
|
112 | + ) |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | - $where = []; |
|
117 | - if (! empty($GRP_IDs)) { |
|
118 | - $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
|
119 | - } |
|
120 | - if (! empty($EVT_IDs)) { |
|
121 | - $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
|
122 | - } |
|
116 | + $where = []; |
|
117 | + if (! empty($GRP_IDs)) { |
|
118 | + $where['GRP_ID'] = ['IN', (array) $GRP_IDs]; |
|
119 | + } |
|
120 | + if (! empty($EVT_IDs)) { |
|
121 | + $where['EVT_ID'] = ['IN', (array) $EVT_IDs]; |
|
122 | + } |
|
123 | 123 | |
124 | - return $this->delete([$where], false); |
|
125 | - } |
|
124 | + return $this->delete([$where], false); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | - /** |
|
129 | - * returns a numerically indexed array |
|
130 | - * with values that correspond to the 'GRP_ID' column |
|
131 | - * where the 'EVT_ID' column matches that of the supplied event |
|
132 | - * |
|
133 | - * @param EE_Event $event |
|
134 | - * @return array |
|
135 | - * @throws EE_Error |
|
136 | - * @throws ReflectionException |
|
137 | - * @since $VID:$ |
|
138 | - */ |
|
139 | - public function messageTemplateGroupIDsForEvent(EE_Event $event): array |
|
140 | - { |
|
141 | - $results = $this->get_col([['EVT_ID' => $event->ID()]], 'GRP_ID'); |
|
142 | - return $results !== false ? $results : []; |
|
143 | - } |
|
128 | + /** |
|
129 | + * returns a numerically indexed array |
|
130 | + * with values that correspond to the 'GRP_ID' column |
|
131 | + * where the 'EVT_ID' column matches that of the supplied event |
|
132 | + * |
|
133 | + * @param EE_Event $event |
|
134 | + * @return array |
|
135 | + * @throws EE_Error |
|
136 | + * @throws ReflectionException |
|
137 | + * @since $VID:$ |
|
138 | + */ |
|
139 | + public function messageTemplateGroupIDsForEvent(EE_Event $event): array |
|
140 | + { |
|
141 | + $results = $this->get_col([['EVT_ID' => $event->ID()]], 'GRP_ID'); |
|
142 | + return $results !== false ? $results : []; |
|
143 | + } |
|
144 | 144 | } |
@@ -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 | } |
@@ -44,27 +44,27 @@ |
||
44 | 44 | $args['PRC_name'] = sanitize_text_field($input['name']); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['order'])) { |
|
47 | + if ( ! empty($input['order'])) { |
|
48 | 48 | $args['PRC_order'] = (int) $input['order']; |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
51 | + if ( ! empty($input['overrides'])) { |
|
52 | 52 | $args['PRC_overrides'] = (int) $input['overrides']; |
53 | 53 | } |
54 | 54 | |
55 | - if (! empty($input['parent'])) { |
|
55 | + if ( ! empty($input['parent'])) { |
|
56 | 56 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
57 | 57 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['priceType'])) { |
|
60 | + if ( ! empty($input['priceType'])) { |
|
61 | 61 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
62 | 62 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
63 | 63 | } |
64 | 64 | |
65 | - if (! empty($input['wpUser'])) { |
|
65 | + if ( ! empty($input['wpUser'])) { |
|
66 | 66 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
67 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + $args['PRC_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return apply_filters( |
@@ -12,64 +12,64 @@ |
||
12 | 12 | */ |
13 | 13 | class PriceMutation |
14 | 14 | { |
15 | - /** |
|
16 | - * Maps the GraphQL input to a format that the model functions can use |
|
17 | - * |
|
18 | - * @param array $input Data coming from the GraphQL mutation query input |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public static function prepareFields(array $input): array |
|
22 | - { |
|
23 | - $args = []; |
|
15 | + /** |
|
16 | + * Maps the GraphQL input to a format that the model functions can use |
|
17 | + * |
|
18 | + * @param array $input Data coming from the GraphQL mutation query input |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public static function prepareFields(array $input): array |
|
22 | + { |
|
23 | + $args = []; |
|
24 | 24 | |
25 | - // amount can be 0 |
|
26 | - if (array_key_exists('amount', $input)) { |
|
27 | - $args['PRC_amount'] = (float) $input['amount']; |
|
28 | - } |
|
25 | + // amount can be 0 |
|
26 | + if (array_key_exists('amount', $input)) { |
|
27 | + $args['PRC_amount'] = (float) $input['amount']; |
|
28 | + } |
|
29 | 29 | |
30 | - if (isset($input['description'])) { |
|
31 | - $args['PRC_desc'] = wp_kses_post($input['description']); |
|
32 | - } |
|
30 | + if (isset($input['description'])) { |
|
31 | + $args['PRC_desc'] = wp_kses_post($input['description']); |
|
32 | + } |
|
33 | 33 | |
34 | - if (array_key_exists('isDefault', $input)) { |
|
35 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | - } |
|
34 | + if (array_key_exists('isDefault', $input)) { |
|
35 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
36 | + } |
|
37 | 37 | |
38 | - if (array_key_exists('isTrashed', $input)) { |
|
39 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | - } |
|
38 | + if (array_key_exists('isTrashed', $input)) { |
|
39 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
40 | + } |
|
41 | 41 | |
42 | - if (isset($input['name'])) { |
|
43 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | - } |
|
42 | + if (isset($input['name'])) { |
|
43 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
44 | + } |
|
45 | 45 | |
46 | - if (! empty($input['order'])) { |
|
47 | - $args['PRC_order'] = (int) $input['order']; |
|
48 | - } |
|
46 | + if (! empty($input['order'])) { |
|
47 | + $args['PRC_order'] = (int) $input['order']; |
|
48 | + } |
|
49 | 49 | |
50 | - if (! empty($input['overrides'])) { |
|
51 | - $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | - } |
|
50 | + if (! empty($input['overrides'])) { |
|
51 | + $args['PRC_overrides'] = (int) $input['overrides']; |
|
52 | + } |
|
53 | 53 | |
54 | - if (! empty($input['parent'])) { |
|
55 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | - } |
|
54 | + if (! empty($input['parent'])) { |
|
55 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
56 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
57 | + } |
|
58 | 58 | |
59 | - if (! empty($input['priceType'])) { |
|
60 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | - } |
|
59 | + if (! empty($input['priceType'])) { |
|
60 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
61 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | + } |
|
63 | 63 | |
64 | - if (! empty($input['wpUser'])) { |
|
65 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | - $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | - } |
|
64 | + if (! empty($input['wpUser'])) { |
|
65 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
66 | + $args['PRC_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
67 | + } |
|
68 | 68 | |
69 | - return apply_filters( |
|
70 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | - $args, |
|
72 | - $input |
|
73 | - ); |
|
74 | - } |
|
69 | + return apply_filters( |
|
70 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__price_args', |
|
71 | + $args, |
|
72 | + $input |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | // $errors = []; |
42 | 42 | |
43 | 43 | try { |
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
44 | + if (empty($input['uniqueInputs']) || ! is_array($input['uniqueInputs'])) { |
|
45 | 45 | throw new OutOfBoundsException( |
46 | 46 | esc_html__('A valid input was not provided.', 'event_espresso') |
47 | 47 | ); |
@@ -10,69 +10,69 @@ |
||
10 | 10 | class BulkEntityMutator extends EntityMutator |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @var callable $entity_mutator . |
|
15 | - */ |
|
16 | - protected $entity_mutator; |
|
13 | + /** |
|
14 | + * @var callable $entity_mutator . |
|
15 | + */ |
|
16 | + protected $entity_mutator; |
|
17 | 17 | |
18 | - /** |
|
19 | - * BulkEntityMutator constructor. |
|
20 | - * |
|
21 | - * @param callable $entity_mutator The mutator for an entity. |
|
22 | - */ |
|
23 | - public function __construct(callable $entity_mutator) |
|
24 | - { |
|
25 | - $this->entity_mutator = $entity_mutator; |
|
26 | - } |
|
27 | - /** |
|
28 | - * Bulk updates entities. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | - { |
|
18 | + /** |
|
19 | + * BulkEntityMutator constructor. |
|
20 | + * |
|
21 | + * @param callable $entity_mutator The mutator for an entity. |
|
22 | + */ |
|
23 | + public function __construct(callable $entity_mutator) |
|
24 | + { |
|
25 | + $this->entity_mutator = $entity_mutator; |
|
26 | + } |
|
27 | + /** |
|
28 | + * Bulk updates entities. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function updateEntities(array $input, AppContext $context, ResolveInfo $info): array |
|
36 | + { |
|
37 | 37 | |
38 | - $updated = []; |
|
39 | - $failed = []; |
|
40 | - // TODO Add meaningful error messages for every failure. |
|
41 | - // $errors = []; |
|
38 | + $updated = []; |
|
39 | + $failed = []; |
|
40 | + // TODO Add meaningful error messages for every failure. |
|
41 | + // $errors = []; |
|
42 | 42 | |
43 | - try { |
|
44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | - throw new OutOfBoundsException( |
|
46 | - esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | - ); |
|
48 | - } |
|
43 | + try { |
|
44 | + if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
45 | + throw new OutOfBoundsException( |
|
46 | + esc_html__('A valid input was not provided.', 'event_espresso') |
|
47 | + ); |
|
48 | + } |
|
49 | 49 | |
50 | - $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
50 | + $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
51 | 51 | |
52 | - foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | - try { |
|
54 | - // values in $uniqueInput will override those in $sharedInput |
|
55 | - $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | - // mutate the individual entity. |
|
57 | - $mutator = $this->entity_mutator; |
|
58 | - $mutator($finalInput, $context, $info); |
|
59 | - // we are here it means the update was successful. |
|
60 | - $updated[] = $uniqueInput['id']; |
|
61 | - } catch (Exception $e) { |
|
62 | - // sorry mate, couldn't help you :( |
|
63 | - $failed[] = $uniqueInput['id']; |
|
64 | - } |
|
65 | - } |
|
66 | - } catch (Exception $exception) { |
|
67 | - EntityMutator::handleExceptions( |
|
68 | - $exception, |
|
69 | - esc_html__( |
|
70 | - 'Could not perform the update because of the following error(s)', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
52 | + foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
53 | + try { |
|
54 | + // values in $uniqueInput will override those in $sharedInput |
|
55 | + $finalInput = array_merge($sharedInput, $uniqueInput); |
|
56 | + // mutate the individual entity. |
|
57 | + $mutator = $this->entity_mutator; |
|
58 | + $mutator($finalInput, $context, $info); |
|
59 | + // we are here it means the update was successful. |
|
60 | + $updated[] = $uniqueInput['id']; |
|
61 | + } catch (Exception $e) { |
|
62 | + // sorry mate, couldn't help you :( |
|
63 | + $failed[] = $uniqueInput['id']; |
|
64 | + } |
|
65 | + } |
|
66 | + } catch (Exception $exception) { |
|
67 | + EntityMutator::handleExceptions( |
|
68 | + $exception, |
|
69 | + esc_html__( |
|
70 | + 'Could not perform the update because of the following error(s)', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - return compact('updated', 'failed'); |
|
77 | - } |
|
76 | + return compact('updated', 'failed'); |
|
77 | + } |
|
78 | 78 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class TicketBulkUpdate extends EntityMutator |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Defines the mutation data modification closure. |
|
13 | - * |
|
14 | - * @param EEM_Ticket $model |
|
15 | - * @param Ticket $type |
|
16 | - * @return callable |
|
17 | - */ |
|
18 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | - { |
|
20 | - $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | - return array($bulkMutator, 'updateEntities'); |
|
23 | - } |
|
11 | + /** |
|
12 | + * Defines the mutation data modification closure. |
|
13 | + * |
|
14 | + * @param EEM_Ticket $model |
|
15 | + * @param Ticket $type |
|
16 | + * @return callable |
|
17 | + */ |
|
18 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
19 | + { |
|
20 | + $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | + return array($bulkMutator, 'updateEntities'); |
|
23 | + } |
|
24 | 24 | } |
@@ -4,97 +4,97 @@ |
||
4 | 4 | |
5 | 5 | class PhpToUnicode |
6 | 6 | { |
7 | - /** |
|
8 | - * array where keys are PHP date format parameters |
|
9 | - * and values are Unicode Date Format substitutions |
|
10 | - */ |
|
11 | - public static $date_formats = [ |
|
12 | - // YEAR |
|
13 | - 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | - 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | - 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | - // MONTH |
|
17 | - 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | - 'n' => 'M', // 1, 2, ..., 12 |
|
19 | - 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | - 'F' => 'MMMM', // January, February, ..., December |
|
21 | - // DAY |
|
22 | - 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | - 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | - 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | - 'j' => 'd', // 1, 2, ..., 31 |
|
26 | - 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | - 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | - 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | - 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | - // WEEK |
|
31 | - 'W' => 'w', |
|
32 | - ]; |
|
7 | + /** |
|
8 | + * array where keys are PHP date format parameters |
|
9 | + * and values are Unicode Date Format substitutions |
|
10 | + */ |
|
11 | + public static $date_formats = [ |
|
12 | + // YEAR |
|
13 | + 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | + 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | + 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | + // MONTH |
|
17 | + 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | + 'n' => 'M', // 1, 2, ..., 12 |
|
19 | + 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | + 'F' => 'MMMM', // January, February, ..., December |
|
21 | + // DAY |
|
22 | + 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | + 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | + 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | + 'j' => 'd', // 1, 2, ..., 31 |
|
26 | + 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | + 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | + 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | + 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | + // WEEK |
|
31 | + 'W' => 'w', |
|
32 | + ]; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * array where keys are PHP time format parameters |
|
37 | - * and values are Unicode Time Format substitutions |
|
38 | - */ |
|
39 | - public static $time_formats = [ |
|
40 | - // 'a' => 'a', // am, pm, no pecific JS alternative |
|
41 | - 'A' => 'a', // AM, PM |
|
42 | - // HOUR |
|
43 | - // convert "g" to an intermediary format |
|
44 | - // to avoid its result getting replaced by "h" |
|
45 | - 'g' => '@', // 1, 2, ..., 12 |
|
46 | - 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | - '@' => 'h', // 1, 2, ..., 12 |
|
48 | - 'G' => '#', // 0, 1, ... 23 |
|
49 | - 'H' => 'HH', // 00, 01, ... 23 |
|
50 | - '#' => 'H', // 0, 1, ... 23 |
|
51 | - // MINUTES & SECONDS |
|
52 | - 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | - 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | - 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | - 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | - ]; |
|
35 | + /** |
|
36 | + * array where keys are PHP time format parameters |
|
37 | + * and values are Unicode Time Format substitutions |
|
38 | + */ |
|
39 | + public static $time_formats = [ |
|
40 | + // 'a' => 'a', // am, pm, no pecific JS alternative |
|
41 | + 'A' => 'a', // AM, PM |
|
42 | + // HOUR |
|
43 | + // convert "g" to an intermediary format |
|
44 | + // to avoid its result getting replaced by "h" |
|
45 | + 'g' => '@', // 1, 2, ..., 12 |
|
46 | + 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | + '@' => 'h', // 1, 2, ..., 12 |
|
48 | + 'G' => '#', // 0, 1, ... 23 |
|
49 | + 'H' => 'HH', // 00, 01, ... 23 |
|
50 | + '#' => 'H', // 0, 1, ... 23 |
|
51 | + // MINUTES & SECONDS |
|
52 | + 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | + 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | + 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | + 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | + ]; |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * array where keys are PHP timezone format parameters |
|
61 | - * and values are Unicode Timezone Format substitutions |
|
62 | - */ |
|
63 | - public static $timezone_formats = [ |
|
64 | - 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | - 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | - 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | - 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | - 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | - ]; |
|
59 | + /** |
|
60 | + * array where keys are PHP timezone format parameters |
|
61 | + * and values are Unicode Timezone Format substitutions |
|
62 | + */ |
|
63 | + public static $timezone_formats = [ |
|
64 | + 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | + 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | + 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | + 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | + 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | + ]; |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param string $date_format |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function convertDateFormat($date_format) |
|
77 | - { |
|
78 | - foreach (PhpToUnicode::$date_formats as $find => $replace) { |
|
79 | - $date_format = (string) str_replace($find, $replace, $date_format); |
|
80 | - } |
|
81 | - return $date_format; |
|
82 | - } |
|
72 | + /** |
|
73 | + * @param string $date_format |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function convertDateFormat($date_format) |
|
77 | + { |
|
78 | + foreach (PhpToUnicode::$date_formats as $find => $replace) { |
|
79 | + $date_format = (string) str_replace($find, $replace, $date_format); |
|
80 | + } |
|
81 | + return $date_format; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @param string $time_format |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function convertTimeFormat($time_format) |
|
90 | - { |
|
91 | - foreach (PhpToUnicode::$time_formats as $find => $replace) { |
|
92 | - $time_format = (string) str_replace($find, $replace, $time_format); |
|
93 | - } |
|
94 | - // and just in case the timezone has been added |
|
95 | - foreach (PhpToUnicode::$timezone_formats as $find => $replace) { |
|
96 | - $time_format = (string) str_replace($find, $replace, $time_format); |
|
97 | - } |
|
98 | - return $time_format; |
|
99 | - } |
|
85 | + /** |
|
86 | + * @param string $time_format |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function convertTimeFormat($time_format) |
|
90 | + { |
|
91 | + foreach (PhpToUnicode::$time_formats as $find => $replace) { |
|
92 | + $time_format = (string) str_replace($find, $replace, $time_format); |
|
93 | + } |
|
94 | + // and just in case the timezone has been added |
|
95 | + foreach (PhpToUnicode::$timezone_formats as $find => $replace) { |
|
96 | + $time_format = (string) str_replace($find, $replace, $time_format); |
|
97 | + } |
|
98 | + return $time_format; |
|
99 | + } |
|
100 | 100 | } |
@@ -10,23 +10,23 @@ discard block |
||
10 | 10 | */ |
11 | 11 | public static $date_formats = [ |
12 | 12 | // YEAR |
13 | - 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | - 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | - 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
13 | + 'y' => 'yy', // 00, 01, ..., 99 |
|
14 | + 'Y' => 'yyyy', // 2000, 2001, ..., 2099 |
|
15 | + 'o' => 'GGGG', // ISO "week-numbering year" 2000, 2001, ..., 2099 |
|
16 | 16 | // MONTH |
17 | - 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | - 'n' => 'M', // 1, 2, ..., 12 |
|
19 | - 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | - 'F' => 'MMMM', // January, February, ..., December |
|
17 | + 'M' => 'MMM', // Jan, Feb, ..., Dec |
|
18 | + 'n' => 'M', // 1, 2, ..., 12 |
|
19 | + 'm' => 'MM', // 01, 02, ..., 12 |
|
20 | + 'F' => 'MMMM', // January, February, ..., December |
|
21 | 21 | // DAY |
22 | - 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | - 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | - 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | - 'j' => 'd', // 1, 2, ..., 31 |
|
26 | - 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | - 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | - 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | - 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
22 | + 'd' => 'dd', // 01, 02, ..., 31 |
|
23 | + 'D' => 'eee', // Sun, Mon, ..., Sat |
|
24 | + 'jS' => 'do', // 1st, 2nd, ..., 31st |
|
25 | + 'j' => 'd', // 1, 2, ..., 31 |
|
26 | + 'l' => 'eeee', // Sunday, Monday, ..., Saturday |
|
27 | + 'N' => 'e', // Day of week 0, 1, ..., 6 |
|
28 | + 'w' => 'i', // ISO Day of week 1, 2, ..., 7 |
|
29 | + 'z' => 'D', // day of the year 0 - 365 to 1 - 366 |
|
30 | 30 | // WEEK |
31 | 31 | 'W' => 'w', |
32 | 32 | ]; |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | // HOUR |
43 | 43 | // convert "g" to an intermediary format |
44 | 44 | // to avoid its result getting replaced by "h" |
45 | - 'g' => '@', // 1, 2, ..., 12 |
|
46 | - 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | - '@' => 'h', // 1, 2, ..., 12 |
|
48 | - 'G' => '#', // 0, 1, ... 23 |
|
49 | - 'H' => 'HH', // 00, 01, ... 23 |
|
50 | - '#' => 'H', // 0, 1, ... 23 |
|
45 | + 'g' => '@', // 1, 2, ..., 12 |
|
46 | + 'h' => 'hh', // 01, 02, ..., 12 |
|
47 | + '@' => 'h', // 1, 2, ..., 12 |
|
48 | + 'G' => '#', // 0, 1, ... 23 |
|
49 | + 'H' => 'HH', // 00, 01, ... 23 |
|
50 | + '#' => 'H', // 0, 1, ... 23 |
|
51 | 51 | // MINUTES & SECONDS |
52 | - 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | - 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | - 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | - 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
52 | + 'i' => 'mm', // minutes 00, 01, ..., 59 |
|
53 | + 's' => 'ss', // seconds 00, 01, ..., 59 |
|
54 | + 'v' => 'SSS', // milliseconds 000, 001, ..., 999 |
|
55 | + 'u' => 'SSS', // microseconds (not in unicode) 000, 001, ..., 999 |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * and values are Unicode Timezone Format substitutions |
62 | 62 | */ |
63 | 63 | public static $timezone_formats = [ |
64 | - 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | - 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | - 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | - 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | - 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
64 | + 'Z' => 'ZZ', // -0100, +0000, ..., +1200 |
|
65 | + 'e' => 'Z', // Timezone identifier UTC, GMT, Atlantic/Azores to -01:00, +00:00, ... +12:00 |
|
66 | + 'T' => 'Z', // Timezone abbreviation EST, MDT to -01:00, +00:00, ... +12:00 |
|
67 | + 'P' => 'Z', // -01:00, +00:00, ... +12:00 |
|
68 | + 'O' => 'ZZ', // -0100, +0000, ..., +1200 |
|
69 | 69 | ]; |
70 | 70 | |
71 | 71 |