@@ -73,17 +73,17 @@ 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 | // Use the proper operator. |
80 | - if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
80 | + if ( ! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
81 | 81 | $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
82 | 82 | } |
83 | - if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
83 | + if ( ! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
84 | 84 | $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
85 | 85 | } |
86 | - if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
86 | + if ( ! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
87 | 87 | $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
88 | 88 | } |
89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Merge the input_fields with the default query_args |
93 | 93 | */ |
94 | - if (! empty($input_fields)) { |
|
94 | + if ( ! empty($input_fields)) { |
|
95 | 95 | $where_params = array_merge($where_params, $input_fields); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->args |
103 | 103 | ); |
104 | 104 | |
105 | - if (! empty($where_params)) { |
|
105 | + if ( ! empty($where_params)) { |
|
106 | 106 | $query_args[] = $where_params; |
107 | 107 | } |
108 | 108 |
@@ -14,130 +14,130 @@ |
||
14 | 14 | */ |
15 | 15 | class FormSectionConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function get_loader_name() |
|
22 | - { |
|
23 | - return 'espresso_formSection'; |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @return EEM_Form_Section |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | - public function get_query() |
|
36 | - { |
|
37 | - return EEM_Form_Section::instance(); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Return an array of item IDs from the query |
|
43 | - * |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | - public function get_ids() |
|
48 | - { |
|
49 | - $results = $this->query->get_col($this->query_args); |
|
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 | - * @throws InvalidArgumentException |
|
61 | - * @throws InvalidDataTypeException |
|
62 | - * @throws InvalidInterfaceException |
|
63 | - */ |
|
64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | - public function get_query_args() |
|
66 | - { |
|
67 | - $where_params = []; |
|
68 | - $query_args = []; |
|
69 | - |
|
70 | - $query_args['limit'] = $this->getLimit(); |
|
71 | - |
|
72 | - // Avoid multiple entries by join. |
|
73 | - $query_args['group_by'] = 'FSC_UUID'; |
|
74 | - |
|
75 | - /** |
|
76 | - * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
77 | - */ |
|
78 | - $input_fields = []; |
|
79 | - if (! empty($this->args['where'])) { |
|
80 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | - |
|
82 | - // Use the proper operator. |
|
83 | - if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
84 | - $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
|
85 | - } |
|
86 | - if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
87 | - $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
|
88 | - } |
|
89 | - if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
90 | - $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Merge the input_fields with the default query_args |
|
96 | - */ |
|
97 | - if (! empty($input_fields)) { |
|
98 | - $where_params = array_merge($where_params, $input_fields); |
|
99 | - } |
|
100 | - |
|
101 | - $where_params = apply_filters( |
|
102 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params', |
|
103 | - $where_params, |
|
104 | - $this->source, |
|
105 | - $this->args |
|
106 | - ); |
|
107 | - |
|
108 | - if (! empty($where_params)) { |
|
109 | - $query_args[] = $where_params; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Return the $query_args |
|
115 | - */ |
|
116 | - return apply_filters( |
|
117 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args', |
|
118 | - $query_args, |
|
119 | - $this->source, |
|
120 | - $this->args |
|
121 | - ); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
127 | - * friendly keys. |
|
128 | - * |
|
129 | - * @param array $where_args |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function sanitizeInputFields($where_args) |
|
133 | - { |
|
134 | - return $this->sanitizeWhereArgsForInputFields( |
|
135 | - $where_args, |
|
136 | - [ |
|
137 | - 'appliesTo' => 'FSC_appliesTo', |
|
138 | - 'belongsTo' => 'FSC_belongsTo', |
|
139 | - 'status' => 'FSC_status', |
|
140 | - ] |
|
141 | - ); |
|
142 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function get_loader_name() |
|
22 | + { |
|
23 | + return 'espresso_formSection'; |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @return EEM_Form_Section |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | + public function get_query() |
|
36 | + { |
|
37 | + return EEM_Form_Section::instance(); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Return an array of item IDs from the query |
|
43 | + * |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | + public function get_ids() |
|
48 | + { |
|
49 | + $results = $this->query->get_col($this->query_args); |
|
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 | + * @throws InvalidArgumentException |
|
61 | + * @throws InvalidDataTypeException |
|
62 | + * @throws InvalidInterfaceException |
|
63 | + */ |
|
64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | + public function get_query_args() |
|
66 | + { |
|
67 | + $where_params = []; |
|
68 | + $query_args = []; |
|
69 | + |
|
70 | + $query_args['limit'] = $this->getLimit(); |
|
71 | + |
|
72 | + // Avoid multiple entries by join. |
|
73 | + $query_args['group_by'] = 'FSC_UUID'; |
|
74 | + |
|
75 | + /** |
|
76 | + * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
77 | + */ |
|
78 | + $input_fields = []; |
|
79 | + if (! empty($this->args['where'])) { |
|
80 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | + |
|
82 | + // Use the proper operator. |
|
83 | + if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
84 | + $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
|
85 | + } |
|
86 | + if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
87 | + $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
|
88 | + } |
|
89 | + if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
90 | + $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Merge the input_fields with the default query_args |
|
96 | + */ |
|
97 | + if (! empty($input_fields)) { |
|
98 | + $where_params = array_merge($where_params, $input_fields); |
|
99 | + } |
|
100 | + |
|
101 | + $where_params = apply_filters( |
|
102 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params', |
|
103 | + $where_params, |
|
104 | + $this->source, |
|
105 | + $this->args |
|
106 | + ); |
|
107 | + |
|
108 | + if (! empty($where_params)) { |
|
109 | + $query_args[] = $where_params; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Return the $query_args |
|
115 | + */ |
|
116 | + return apply_filters( |
|
117 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args', |
|
118 | + $query_args, |
|
119 | + $this->source, |
|
120 | + $this->args |
|
121 | + ); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
127 | + * friendly keys. |
|
128 | + * |
|
129 | + * @param array $where_args |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function sanitizeInputFields($where_args) |
|
133 | + { |
|
134 | + return $this->sanitizeWhereArgsForInputFields( |
|
135 | + $where_args, |
|
136 | + [ |
|
137 | + 'appliesTo' => 'FSC_appliesTo', |
|
138 | + 'belongsTo' => 'FSC_belongsTo', |
|
139 | + 'status' => 'FSC_status', |
|
140 | + ] |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | } |
@@ -152,10 +152,10 @@ |
||
152 | 152 | ]; |
153 | 153 | // this model is generally available for reading |
154 | 154 | $restrictions = []; |
155 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
156 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
157 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
158 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
155 | + $restrictions[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
156 | + $restrictions[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
157 | + $restrictions[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
158 | + $restrictions[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
159 | 159 | $this->_cap_restriction_generators = $restrictions; |
160 | 160 | parent::__construct($timezone); |
161 | 161 | $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
@@ -21,245 +21,245 @@ |
||
21 | 21 | */ |
22 | 22 | class EEM_Form_Section extends EEM_Base |
23 | 23 | { |
24 | - const APPLIES_TO_ALL = 'all'; |
|
24 | + const APPLIES_TO_ALL = 'all'; |
|
25 | 25 | |
26 | - const APPLIES_TO_PRIMARY = 'primary'; |
|
26 | + const APPLIES_TO_PRIMARY = 'primary'; |
|
27 | 27 | |
28 | - const APPLIES_TO_PURCHASER = 'purchaser'; |
|
28 | + const APPLIES_TO_PURCHASER = 'purchaser'; |
|
29 | 29 | |
30 | - const APPLIES_TO_REGISTRANTS = 'registrants'; |
|
30 | + const APPLIES_TO_REGISTRANTS = 'registrants'; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var EEM_Form_Section |
|
34 | - */ |
|
35 | - protected static $_instance; |
|
32 | + /** |
|
33 | + * @var EEM_Form_Section |
|
34 | + */ |
|
35 | + protected static $_instance; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @var RequestInterface |
|
39 | - */ |
|
40 | - private $request; |
|
37 | + /** |
|
38 | + * @var RequestInterface |
|
39 | + */ |
|
40 | + private $request; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var array |
|
44 | - */ |
|
45 | - private $valid_applies_to_options; |
|
42 | + /** |
|
43 | + * @var array |
|
44 | + */ |
|
45 | + private $valid_applies_to_options; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * EEM_Form_Section constructor. |
|
50 | - * |
|
51 | - * @param FormStatus $form_status |
|
52 | - * @param string|null $timezone |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - protected function __construct(FormStatus $form_status, $timezone) |
|
56 | - { |
|
57 | - $this->valid_applies_to_options = apply_filters( |
|
58 | - 'FHEE__EEM_Form_Section__valid_applies_to_options', |
|
59 | - [ |
|
60 | - EEM_Form_Section::APPLIES_TO_ALL => esc_html__('All Registrants', 'event_espresso'), |
|
61 | - EEM_Form_Section::APPLIES_TO_PRIMARY => esc_html__('Primary Registrant Only', 'event_espresso'), |
|
62 | - EEM_Form_Section::APPLIES_TO_PURCHASER => esc_html__('Purchasing Agent', 'event_espresso'), |
|
63 | - EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'), |
|
64 | - ] |
|
65 | - ); |
|
48 | + /** |
|
49 | + * EEM_Form_Section constructor. |
|
50 | + * |
|
51 | + * @param FormStatus $form_status |
|
52 | + * @param string|null $timezone |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + protected function __construct(FormStatus $form_status, $timezone) |
|
56 | + { |
|
57 | + $this->valid_applies_to_options = apply_filters( |
|
58 | + 'FHEE__EEM_Form_Section__valid_applies_to_options', |
|
59 | + [ |
|
60 | + EEM_Form_Section::APPLIES_TO_ALL => esc_html__('All Registrants', 'event_espresso'), |
|
61 | + EEM_Form_Section::APPLIES_TO_PRIMARY => esc_html__('Primary Registrant Only', 'event_espresso'), |
|
62 | + EEM_Form_Section::APPLIES_TO_PURCHASER => esc_html__('Purchasing Agent', 'event_espresso'), |
|
63 | + EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'), |
|
64 | + ] |
|
65 | + ); |
|
66 | 66 | |
67 | - $this->singular_item = esc_html__('Form Section', 'event_espresso'); |
|
68 | - $this->plural_item = esc_html__('Form Sections', 'event_espresso'); |
|
67 | + $this->singular_item = esc_html__('Form Section', 'event_espresso'); |
|
68 | + $this->plural_item = esc_html__('Form Sections', 'event_espresso'); |
|
69 | 69 | |
70 | - $this->_tables = [ |
|
71 | - 'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'), |
|
72 | - ]; |
|
73 | - $this->_fields = [ |
|
74 | - 'Form_Section' => [ |
|
75 | - 'FSC_UUID' => new EE_Primary_Key_String_Field( |
|
76 | - 'FSC_UUID', |
|
77 | - esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso') |
|
78 | - ), |
|
79 | - 'FSC_appliesTo' => new EE_Enum_Text_Field( |
|
80 | - 'FSC_appliesTo', |
|
81 | - esc_html( |
|
82 | - sprintf( |
|
83 | - /* translators: 1 class name */ |
|
84 | - __( |
|
85 | - 'Form user type that this form section should be presented to. Values correspond to the %s constants.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - 'EEM_Form_Section::APPLIES_TO_*' |
|
89 | - ) |
|
90 | - ), |
|
91 | - false, |
|
92 | - EEM_Form_Section::APPLIES_TO_ALL, |
|
93 | - $this->valid_applies_to_options |
|
94 | - ), |
|
95 | - 'FSC_attributes' => new EE_JSON_Field( |
|
96 | - 'FSC_attributes', |
|
97 | - esc_html__( |
|
98 | - 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
99 | - 'event_espresso' |
|
100 | - ), |
|
101 | - false, |
|
102 | - '{}' |
|
103 | - ), |
|
104 | - 'FSC_belongsTo' => new EE_Plain_Text_Field( |
|
105 | - 'FSC_belongsTo', |
|
106 | - esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'), |
|
107 | - false, |
|
108 | - '' |
|
109 | - ), |
|
110 | - 'FSC_label' => new EE_JSON_Field( |
|
111 | - 'FSC_label', |
|
112 | - esc_html__( |
|
113 | - 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - false, |
|
117 | - '{}' |
|
118 | - ), |
|
119 | - 'FSC_order' => new EE_Integer_Field( |
|
120 | - 'FSC_order', |
|
121 | - esc_html__('Order in which form section appears in a form.', 'event_espresso'), |
|
122 | - false, |
|
123 | - 0 |
|
124 | - ), |
|
125 | - 'FSC_status' => new EE_Enum_Text_Field( |
|
126 | - 'FSC_status', |
|
127 | - esc_html( |
|
128 | - sprintf( |
|
129 | - /* translators: 1 class name */ |
|
130 | - __( |
|
131 | - 'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.', |
|
132 | - 'event_espresso' |
|
133 | - ), |
|
134 | - 'EventEspresso\core\services\form\meta\FormStatus' |
|
135 | - ) |
|
136 | - ), |
|
137 | - false, |
|
138 | - FormStatus::ACTIVE, |
|
139 | - $form_status->validStatusOptions() |
|
140 | - ), |
|
141 | - 'FSC_wpUser' => new EE_WP_User_Field( |
|
142 | - 'FSC_wpUser', |
|
143 | - esc_html__('ID of the WP User that created this form section.', 'event_espresso'), |
|
144 | - false |
|
145 | - ), |
|
146 | - ], |
|
147 | - ]; |
|
148 | - $this->_model_relations = [ |
|
149 | - 'Form_Element' => new EE_Has_Many_Relation(), |
|
150 | - 'Form_Submission' => new EE_Has_Many_Relation(), |
|
151 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
152 | - ]; |
|
153 | - // this model is generally available for reading |
|
154 | - $restrictions = []; |
|
155 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
156 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
157 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
158 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
159 | - $this->_cap_restriction_generators = $restrictions; |
|
160 | - parent::__construct($timezone); |
|
161 | - $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
162 | - } |
|
70 | + $this->_tables = [ |
|
71 | + 'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'), |
|
72 | + ]; |
|
73 | + $this->_fields = [ |
|
74 | + 'Form_Section' => [ |
|
75 | + 'FSC_UUID' => new EE_Primary_Key_String_Field( |
|
76 | + 'FSC_UUID', |
|
77 | + esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso') |
|
78 | + ), |
|
79 | + 'FSC_appliesTo' => new EE_Enum_Text_Field( |
|
80 | + 'FSC_appliesTo', |
|
81 | + esc_html( |
|
82 | + sprintf( |
|
83 | + /* translators: 1 class name */ |
|
84 | + __( |
|
85 | + 'Form user type that this form section should be presented to. Values correspond to the %s constants.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + 'EEM_Form_Section::APPLIES_TO_*' |
|
89 | + ) |
|
90 | + ), |
|
91 | + false, |
|
92 | + EEM_Form_Section::APPLIES_TO_ALL, |
|
93 | + $this->valid_applies_to_options |
|
94 | + ), |
|
95 | + 'FSC_attributes' => new EE_JSON_Field( |
|
96 | + 'FSC_attributes', |
|
97 | + esc_html__( |
|
98 | + 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
99 | + 'event_espresso' |
|
100 | + ), |
|
101 | + false, |
|
102 | + '{}' |
|
103 | + ), |
|
104 | + 'FSC_belongsTo' => new EE_Plain_Text_Field( |
|
105 | + 'FSC_belongsTo', |
|
106 | + esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'), |
|
107 | + false, |
|
108 | + '' |
|
109 | + ), |
|
110 | + 'FSC_label' => new EE_JSON_Field( |
|
111 | + 'FSC_label', |
|
112 | + esc_html__( |
|
113 | + 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + false, |
|
117 | + '{}' |
|
118 | + ), |
|
119 | + 'FSC_order' => new EE_Integer_Field( |
|
120 | + 'FSC_order', |
|
121 | + esc_html__('Order in which form section appears in a form.', 'event_espresso'), |
|
122 | + false, |
|
123 | + 0 |
|
124 | + ), |
|
125 | + 'FSC_status' => new EE_Enum_Text_Field( |
|
126 | + 'FSC_status', |
|
127 | + esc_html( |
|
128 | + sprintf( |
|
129 | + /* translators: 1 class name */ |
|
130 | + __( |
|
131 | + 'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.', |
|
132 | + 'event_espresso' |
|
133 | + ), |
|
134 | + 'EventEspresso\core\services\form\meta\FormStatus' |
|
135 | + ) |
|
136 | + ), |
|
137 | + false, |
|
138 | + FormStatus::ACTIVE, |
|
139 | + $form_status->validStatusOptions() |
|
140 | + ), |
|
141 | + 'FSC_wpUser' => new EE_WP_User_Field( |
|
142 | + 'FSC_wpUser', |
|
143 | + esc_html__('ID of the WP User that created this form section.', 'event_espresso'), |
|
144 | + false |
|
145 | + ), |
|
146 | + ], |
|
147 | + ]; |
|
148 | + $this->_model_relations = [ |
|
149 | + 'Form_Element' => new EE_Has_Many_Relation(), |
|
150 | + 'Form_Submission' => new EE_Has_Many_Relation(), |
|
151 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
152 | + ]; |
|
153 | + // this model is generally available for reading |
|
154 | + $restrictions = []; |
|
155 | + $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
156 | + $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
157 | + $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
158 | + $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
159 | + $this->_cap_restriction_generators = $restrictions; |
|
160 | + parent::__construct($timezone); |
|
161 | + $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
162 | + } |
|
163 | 163 | |
164 | 164 | |
165 | - /** |
|
166 | - * @param array $query_params |
|
167 | - * @return array |
|
168 | - */ |
|
169 | - private function addDefaultWhereConditions(array $query_params) |
|
170 | - { |
|
171 | - // might need to add a way to identify GQL requests for admin domains |
|
172 | - $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
173 | - $query_params['default_where_conditions'] = $admin_request |
|
174 | - ? EEM_Base::default_where_conditions_none |
|
175 | - : EEM_Base::default_where_conditions_all; |
|
176 | - return $query_params; |
|
177 | - } |
|
165 | + /** |
|
166 | + * @param array $query_params |
|
167 | + * @return array |
|
168 | + */ |
|
169 | + private function addDefaultWhereConditions(array $query_params) |
|
170 | + { |
|
171 | + // might need to add a way to identify GQL requests for admin domains |
|
172 | + $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
173 | + $query_params['default_where_conditions'] = $admin_request |
|
174 | + ? EEM_Base::default_where_conditions_none |
|
175 | + : EEM_Base::default_where_conditions_all; |
|
176 | + return $query_params; |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | - /** |
|
181 | - * form sections should always be sorted in ascending order via the FSC_order field |
|
182 | - * |
|
183 | - * @param array $query_params |
|
184 | - * @return array |
|
185 | - */ |
|
186 | - private function addOrderByQueryParams(array $query_params) |
|
187 | - { |
|
188 | - $query_params['order_by'] = ['FSC_order' => 'ASC']; |
|
189 | - return $query_params; |
|
190 | - } |
|
180 | + /** |
|
181 | + * form sections should always be sorted in ascending order via the FSC_order field |
|
182 | + * |
|
183 | + * @param array $query_params |
|
184 | + * @return array |
|
185 | + */ |
|
186 | + private function addOrderByQueryParams(array $query_params) |
|
187 | + { |
|
188 | + $query_params['order_by'] = ['FSC_order' => 'ASC']; |
|
189 | + return $query_params; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | - /** |
|
194 | - * returns an array of Form Sections that should be added by default to new Events |
|
195 | - * |
|
196 | - * @return EE_Form_Section[] |
|
197 | - * @throws EE_Error |
|
198 | - */ |
|
199 | - public function getDefaultFormSections() |
|
200 | - { |
|
201 | - return $this->getFormSections(['FSC_status' => FormStatus::DEFAULT]); |
|
202 | - } |
|
193 | + /** |
|
194 | + * returns an array of Form Sections that should be added by default to new Events |
|
195 | + * |
|
196 | + * @return EE_Form_Section[] |
|
197 | + * @throws EE_Error |
|
198 | + */ |
|
199 | + public function getDefaultFormSections() |
|
200 | + { |
|
201 | + return $this->getFormSections(['FSC_status' => FormStatus::DEFAULT]); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | |
205 | - /** |
|
206 | - * returns an array of Form Sections for the specified parent Form Section |
|
207 | - * |
|
208 | - * @param string $FSC_UUID |
|
209 | - * @return EE_Form_Section[] |
|
210 | - * @throws EE_Error |
|
211 | - */ |
|
212 | - public function getChildFormSections($FSC_UUID) |
|
213 | - { |
|
214 | - return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]); |
|
215 | - } |
|
205 | + /** |
|
206 | + * returns an array of Form Sections for the specified parent Form Section |
|
207 | + * |
|
208 | + * @param string $FSC_UUID |
|
209 | + * @return EE_Form_Section[] |
|
210 | + * @throws EE_Error |
|
211 | + */ |
|
212 | + public function getChildFormSections($FSC_UUID) |
|
213 | + { |
|
214 | + return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * @return EE_Form_Section[] |
|
220 | - * @throws EE_Error |
|
221 | - * @param mixed[] $where_params |
|
222 | - */ |
|
223 | - public function getFormSections($where_params) |
|
224 | - { |
|
225 | - $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
226 | - $query_params = $this->addOrderByQueryParams($query_params); |
|
227 | - return $this->get_all($query_params); |
|
228 | - } |
|
218 | + /** |
|
219 | + * @return EE_Form_Section[] |
|
220 | + * @throws EE_Error |
|
221 | + * @param mixed[] $where_params |
|
222 | + */ |
|
223 | + public function getFormSections($where_params) |
|
224 | + { |
|
225 | + $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
226 | + $query_params = $this->addOrderByQueryParams($query_params); |
|
227 | + return $this->get_all($query_params); |
|
228 | + } |
|
229 | 229 | |
230 | 230 | |
231 | - /** |
|
232 | - * returns an array of Form Sections for the specified Event |
|
233 | - * |
|
234 | - * @param EE_Event $event |
|
235 | - * @return EE_Form_Section[] |
|
236 | - * @throws EE_Error |
|
237 | - * @throws ReflectionException |
|
238 | - */ |
|
239 | - public function getFormSectionsForEvent($event) |
|
240 | - { |
|
241 | - $FSC_UUID = $event->registrationFormUuid(); |
|
242 | - return ! empty($FSC_UUID) |
|
243 | - ? $this->getFormSections( |
|
244 | - [ |
|
245 | - 'OR' => [ |
|
246 | - 'FSC_UUID' => $FSC_UUID, // top level form |
|
247 | - 'FSC_belongsTo' => $FSC_UUID, // child form sections |
|
248 | - ] |
|
249 | - ] |
|
250 | - ) |
|
251 | - : []; |
|
252 | - } |
|
231 | + /** |
|
232 | + * returns an array of Form Sections for the specified Event |
|
233 | + * |
|
234 | + * @param EE_Event $event |
|
235 | + * @return EE_Form_Section[] |
|
236 | + * @throws EE_Error |
|
237 | + * @throws ReflectionException |
|
238 | + */ |
|
239 | + public function getFormSectionsForEvent($event) |
|
240 | + { |
|
241 | + $FSC_UUID = $event->registrationFormUuid(); |
|
242 | + return ! empty($FSC_UUID) |
|
243 | + ? $this->getFormSections( |
|
244 | + [ |
|
245 | + 'OR' => [ |
|
246 | + 'FSC_UUID' => $FSC_UUID, // top level form |
|
247 | + 'FSC_belongsTo' => $FSC_UUID, // child form sections |
|
248 | + ] |
|
249 | + ] |
|
250 | + ) |
|
251 | + : []; |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | - /** |
|
256 | - * @param bool $constants_only |
|
257 | - * @return array |
|
258 | - */ |
|
259 | - public function validAppliesToOptions($constants_only = false) |
|
260 | - { |
|
261 | - return $constants_only |
|
262 | - ? array_keys($this->valid_applies_to_options) |
|
263 | - : $this->valid_applies_to_options; |
|
264 | - } |
|
255 | + /** |
|
256 | + * @param bool $constants_only |
|
257 | + * @return array |
|
258 | + */ |
|
259 | + public function validAppliesToOptions($constants_only = false) |
|
260 | + { |
|
261 | + return $constants_only |
|
262 | + ? array_keys($this->valid_applies_to_options) |
|
263 | + : $this->valid_applies_to_options; |
|
264 | + } |
|
265 | 265 | } |
@@ -73,14 +73,14 @@ 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 | // Use the proper operator. |
80 | - if (! empty($input_fields['FSC_UUID']) && is_array($input_fields['FSC_UUID'])) { |
|
80 | + if ( ! empty($input_fields['FSC_UUID']) && is_array($input_fields['FSC_UUID'])) { |
|
81 | 81 | $input_fields['FSC_UUID'] = ['IN', $input_fields['FSC_UUID']]; |
82 | 82 | } |
83 | - if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
83 | + if ( ! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
84 | 84 | $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
85 | 85 | } |
86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * Merge the input_fields with the default query_args |
90 | 90 | */ |
91 | - if (! empty($input_fields)) { |
|
91 | + if ( ! empty($input_fields)) { |
|
92 | 92 | $where_params = array_merge($where_params, $input_fields); |
93 | 93 | } |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->args |
100 | 100 | ); |
101 | 101 | |
102 | - if (! empty($where_params)) { |
|
102 | + if ( ! empty($where_params)) { |
|
103 | 103 | $query_args[] = $where_params; |
104 | 104 | } |
105 | 105 |
@@ -14,125 +14,125 @@ |
||
14 | 14 | */ |
15 | 15 | class FormElementConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - /** |
|
19 | - * @return string |
|
20 | - */ |
|
21 | - public function get_loader_name() |
|
22 | - { |
|
23 | - return 'espresso_formElement'; |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @return EEM_Form_Element |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | - public function get_query() |
|
36 | - { |
|
37 | - return EEM_Form_Element::instance(); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Return an array of item IDs from the query |
|
43 | - * |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | - public function get_ids() |
|
48 | - { |
|
49 | - $results = $this->query->get_col($this->query_args); |
|
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 | - * @throws InvalidArgumentException |
|
61 | - * @throws InvalidDataTypeException |
|
62 | - * @throws InvalidInterfaceException |
|
63 | - */ |
|
64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | - public function get_query_args() |
|
66 | - { |
|
67 | - $where_params = []; |
|
68 | - $query_args = []; |
|
69 | - |
|
70 | - $query_args['limit'] = $this->getLimit(); |
|
71 | - |
|
72 | - // Avoid multiple entries by join. |
|
73 | - $query_args['group_by'] = 'FIN_UUID'; |
|
74 | - |
|
75 | - /** |
|
76 | - * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
77 | - */ |
|
78 | - $input_fields = []; |
|
79 | - if (! empty($this->args['where'])) { |
|
80 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | - |
|
82 | - // Use the proper operator. |
|
83 | - if (! empty($input_fields['FSC_UUID']) && is_array($input_fields['FSC_UUID'])) { |
|
84 | - $input_fields['FSC_UUID'] = ['IN', $input_fields['FSC_UUID']]; |
|
85 | - } |
|
86 | - if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
87 | - $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Merge the input_fields with the default query_args |
|
93 | - */ |
|
94 | - if (! empty($input_fields)) { |
|
95 | - $where_params = array_merge($where_params, $input_fields); |
|
96 | - } |
|
97 | - |
|
98 | - $where_params = apply_filters( |
|
99 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_where_params', |
|
100 | - $where_params, |
|
101 | - $this->source, |
|
102 | - $this->args |
|
103 | - ); |
|
104 | - |
|
105 | - if (! empty($where_params)) { |
|
106 | - $query_args[] = $where_params; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Return the $query_args |
|
112 | - */ |
|
113 | - return apply_filters( |
|
114 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_query_args', |
|
115 | - $query_args, |
|
116 | - $this->source, |
|
117 | - $this->args |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
123 | - * friendly keys. |
|
124 | - * |
|
125 | - * @param array $where_args |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - public function sanitizeInputFields($where_args) |
|
129 | - { |
|
130 | - return $this->sanitizeWhereArgsForInputFields( |
|
131 | - $where_args, |
|
132 | - [ |
|
133 | - 'belongsTo' => 'FSC_UUID', |
|
134 | - 'status' => 'FIN_status', |
|
135 | - ] |
|
136 | - ); |
|
137 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + /** |
|
19 | + * @return string |
|
20 | + */ |
|
21 | + public function get_loader_name() |
|
22 | + { |
|
23 | + return 'espresso_formElement'; |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @return EEM_Form_Element |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | + public function get_query() |
|
36 | + { |
|
37 | + return EEM_Form_Element::instance(); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Return an array of item IDs from the query |
|
43 | + * |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | + public function get_ids() |
|
48 | + { |
|
49 | + $results = $this->query->get_col($this->query_args); |
|
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 | + * @throws InvalidArgumentException |
|
61 | + * @throws InvalidDataTypeException |
|
62 | + * @throws InvalidInterfaceException |
|
63 | + */ |
|
64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | + public function get_query_args() |
|
66 | + { |
|
67 | + $where_params = []; |
|
68 | + $query_args = []; |
|
69 | + |
|
70 | + $query_args['limit'] = $this->getLimit(); |
|
71 | + |
|
72 | + // Avoid multiple entries by join. |
|
73 | + $query_args['group_by'] = 'FIN_UUID'; |
|
74 | + |
|
75 | + /** |
|
76 | + * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
77 | + */ |
|
78 | + $input_fields = []; |
|
79 | + if (! empty($this->args['where'])) { |
|
80 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | + |
|
82 | + // Use the proper operator. |
|
83 | + if (! empty($input_fields['FSC_UUID']) && is_array($input_fields['FSC_UUID'])) { |
|
84 | + $input_fields['FSC_UUID'] = ['IN', $input_fields['FSC_UUID']]; |
|
85 | + } |
|
86 | + if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
87 | + $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Merge the input_fields with the default query_args |
|
93 | + */ |
|
94 | + if (! empty($input_fields)) { |
|
95 | + $where_params = array_merge($where_params, $input_fields); |
|
96 | + } |
|
97 | + |
|
98 | + $where_params = apply_filters( |
|
99 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_where_params', |
|
100 | + $where_params, |
|
101 | + $this->source, |
|
102 | + $this->args |
|
103 | + ); |
|
104 | + |
|
105 | + if (! empty($where_params)) { |
|
106 | + $query_args[] = $where_params; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Return the $query_args |
|
112 | + */ |
|
113 | + return apply_filters( |
|
114 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_query_args', |
|
115 | + $query_args, |
|
116 | + $this->source, |
|
117 | + $this->args |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
123 | + * friendly keys. |
|
124 | + * |
|
125 | + * @param array $where_args |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + public function sanitizeInputFields($where_args) |
|
129 | + { |
|
130 | + return $this->sanitizeWhereArgsForInputFields( |
|
131 | + $where_args, |
|
132 | + [ |
|
133 | + 'belongsTo' => 'FSC_UUID', |
|
134 | + 'status' => 'FIN_status', |
|
135 | + ] |
|
136 | + ); |
|
137 | + } |
|
138 | 138 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $args['FSC_status'] = sanitize_text_field($input['status']); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($input['wpUser'])) { |
|
52 | + if ( ! empty($input['wpUser'])) { |
|
53 | 53 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
54 | 54 | $args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
55 | 55 | } |
@@ -14,54 +14,54 @@ |
||
14 | 14 | */ |
15 | 15 | class FormSectionMutation |
16 | 16 | { |
17 | - /** |
|
18 | - * Maps the GraphQL input to a format that the model functions can use |
|
19 | - * |
|
20 | - * @param array $input Data coming from the GraphQL mutation query input |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - public static function prepareFields($input) |
|
24 | - { |
|
25 | - $args = []; |
|
17 | + /** |
|
18 | + * Maps the GraphQL input to a format that the model functions can use |
|
19 | + * |
|
20 | + * @param array $input Data coming from the GraphQL mutation query input |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + public static function prepareFields($input) |
|
24 | + { |
|
25 | + $args = []; |
|
26 | 26 | |
27 | - if (isset($input['id'])) { |
|
28 | - $args['FSC_UUID'] = sanitize_text_field($input['id']); |
|
29 | - } |
|
27 | + if (isset($input['id'])) { |
|
28 | + $args['FSC_UUID'] = sanitize_text_field($input['id']); |
|
29 | + } |
|
30 | 30 | |
31 | - if (isset($input['appliesTo'])) { |
|
32 | - $args['FSC_appliesTo'] = sanitize_text_field($input['appliesTo']); |
|
33 | - } |
|
31 | + if (isset($input['appliesTo'])) { |
|
32 | + $args['FSC_appliesTo'] = sanitize_text_field($input['appliesTo']); |
|
33 | + } |
|
34 | 34 | |
35 | - if (isset($input['attributes'])) { |
|
36 | - $args['FSC_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson(); |
|
37 | - } |
|
35 | + if (isset($input['attributes'])) { |
|
36 | + $args['FSC_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson(); |
|
37 | + } |
|
38 | 38 | |
39 | - if (isset($input['belongsTo'])) { |
|
40 | - $args['FSC_belongsTo'] = sanitize_text_field($input['belongsTo']); |
|
41 | - } |
|
39 | + if (isset($input['belongsTo'])) { |
|
40 | + $args['FSC_belongsTo'] = sanitize_text_field($input['belongsTo']); |
|
41 | + } |
|
42 | 42 | |
43 | - if (isset($input['label'])) { |
|
44 | - $args['FSC_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson(); |
|
45 | - } |
|
43 | + if (isset($input['label'])) { |
|
44 | + $args['FSC_label'] = FormLabel::fromJson(sanitize_text_field($input['label']))->toJson(); |
|
45 | + } |
|
46 | 46 | |
47 | - // order can be 0 |
|
48 | - if (array_key_exists('order', $input)) { |
|
49 | - $args['FSC_order'] = absint($input['order']); |
|
50 | - } |
|
47 | + // order can be 0 |
|
48 | + if (array_key_exists('order', $input)) { |
|
49 | + $args['FSC_order'] = absint($input['order']); |
|
50 | + } |
|
51 | 51 | |
52 | - if (isset($input['status'])) { |
|
53 | - $args['FSC_status'] = sanitize_text_field($input['status']); |
|
54 | - } |
|
52 | + if (isset($input['status'])) { |
|
53 | + $args['FSC_status'] = sanitize_text_field($input['status']); |
|
54 | + } |
|
55 | 55 | |
56 | - if (! empty($input['wpUser'])) { |
|
57 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
58 | - $args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
59 | - } |
|
56 | + if (! empty($input['wpUser'])) { |
|
57 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
58 | + $args['FSC_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
59 | + } |
|
60 | 60 | |
61 | - return apply_filters( |
|
62 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_section_args', |
|
63 | - $args, |
|
64 | - $input |
|
65 | - ); |
|
66 | - } |
|
61 | + return apply_filters( |
|
62 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_section_args', |
|
63 | + $args, |
|
64 | + $input |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | { |
70 | 70 | $values = []; |
71 | 71 | foreach ($this->valid_status_options as $value => $description) { |
72 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | + $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description'); |
|
73 | 73 | } |
74 | 74 | return $values; |
75 | 75 | } |
@@ -14,74 +14,74 @@ |
||
14 | 14 | */ |
15 | 15 | class FormStatus |
16 | 16 | { |
17 | - /** |
|
18 | - * indicates that element is not archived or trashed |
|
19 | - */ |
|
20 | - const ACTIVE = 'active'; |
|
17 | + /** |
|
18 | + * indicates that element is not archived or trashed |
|
19 | + */ |
|
20 | + const ACTIVE = 'active'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that element is archived and should no longer be displayed on public forms |
|
24 | - * but may still be required due to existing answers when form was completed prior to input being archived |
|
25 | - */ |
|
26 | - const ARCHIVED = 'archived'; |
|
22 | + /** |
|
23 | + * indicates that element is archived and should no longer be displayed on public forms |
|
24 | + * but may still be required due to existing answers when form was completed prior to input being archived |
|
25 | + */ |
|
26 | + const ARCHIVED = 'archived'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * indicates that element should be automatically added to newly created forms |
|
30 | - */ |
|
31 | - const DEFAULT = 'default'; |
|
28 | + /** |
|
29 | + * indicates that element should be automatically added to newly created forms |
|
30 | + */ |
|
31 | + const DEFAULT = 'default'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * indicates that a copy of the form section will be saved for use in other events but not loaded by default |
|
35 | - */ |
|
36 | - const SHARED = 'shared'; |
|
33 | + /** |
|
34 | + * indicates that a copy of the form section will be saved for use in other events but not loaded by default |
|
35 | + */ |
|
36 | + const SHARED = 'shared'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
40 | - */ |
|
41 | - const TRASHED = 'trashed'; |
|
38 | + /** |
|
39 | + * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
40 | + */ |
|
41 | + const TRASHED = 'trashed'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - private $valid_status_options; |
|
43 | + /** |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + private $valid_status_options; |
|
47 | 47 | |
48 | 48 | |
49 | - public function __construct() |
|
50 | - { |
|
51 | - $this->valid_status_options = apply_filters( |
|
52 | - 'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options', |
|
53 | - [ |
|
54 | - FormStatus::ACTIVE => esc_html__('Active', 'event_espresso'), |
|
55 | - FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
56 | - FormStatus::DEFAULT => esc_html__('Default', 'event_espresso'), |
|
57 | - FormStatus::SHARED => esc_html__('Shared', 'event_espresso'), |
|
58 | - FormStatus::TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
59 | - ] |
|
60 | - ); |
|
61 | - } |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + $this->valid_status_options = apply_filters( |
|
52 | + 'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options', |
|
53 | + [ |
|
54 | + FormStatus::ACTIVE => esc_html__('Active', 'event_espresso'), |
|
55 | + FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
56 | + FormStatus::DEFAULT => esc_html__('Default', 'event_espresso'), |
|
57 | + FormStatus::SHARED => esc_html__('Shared', 'event_espresso'), |
|
58 | + FormStatus::TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
59 | + ] |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function getFormStatusValues() |
|
68 | - { |
|
69 | - $values = []; |
|
70 | - foreach ($this->valid_status_options as $value => $description) { |
|
71 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | - } |
|
73 | - return $values; |
|
74 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function getFormStatusValues() |
|
68 | + { |
|
69 | + $values = []; |
|
70 | + foreach ($this->valid_status_options as $value => $description) { |
|
71 | + $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | + } |
|
73 | + return $values; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @param bool $constants_only |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - public function validStatusOptions($constants_only = false) |
|
82 | - { |
|
83 | - return $constants_only |
|
84 | - ? array_keys($this->valid_status_options) |
|
85 | - : $this->valid_status_options; |
|
86 | - } |
|
77 | + /** |
|
78 | + * @param bool $constants_only |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + public function validStatusOptions($constants_only = false) |
|
82 | + { |
|
83 | + return $constants_only |
|
84 | + ? array_keys($this->valid_status_options) |
|
85 | + : $this->valid_status_options; |
|
86 | + } |
|
87 | 87 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | { |
117 | 117 | $values = []; |
118 | 118 | foreach ($this->valid_type_options as $value => $description) { |
119 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
119 | + $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description'); |
|
120 | 120 | } |
121 | 121 | return $values; |
122 | 122 | } |
@@ -22,124 +22,124 @@ |
||
22 | 22 | */ |
23 | 23 | class InputTypes |
24 | 24 | { |
25 | - /** |
|
26 | - * @var Block |
|
27 | - */ |
|
28 | - private $block; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Button |
|
32 | - */ |
|
33 | - private $button; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var DateTime |
|
37 | - */ |
|
38 | - private $datetime; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var Input |
|
42 | - */ |
|
43 | - private $input; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var Number |
|
47 | - */ |
|
48 | - private $number; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var Phone |
|
52 | - */ |
|
53 | - private $phone; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var Select |
|
57 | - */ |
|
58 | - private $select; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var Text |
|
62 | - */ |
|
63 | - private $text; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $valid_type_options; |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * InputTypes constructor. |
|
73 | - * |
|
74 | - * @param Block $block |
|
75 | - * @param Button $button |
|
76 | - * @param DateTime $datetime |
|
77 | - * @param Input $input |
|
78 | - * @param Number $number |
|
79 | - * @param Phone $phone |
|
80 | - * @param Select $select |
|
81 | - * @param Text $text |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - Block $block, |
|
85 | - Button $button, |
|
86 | - DateTime $datetime, |
|
87 | - Input $input, |
|
88 | - Number $number, |
|
89 | - Phone $phone, |
|
90 | - Select $select, |
|
91 | - Text $text |
|
92 | - ) { |
|
93 | - $this->block = $block; |
|
94 | - $this->button = $button; |
|
95 | - $this->datetime = $datetime; |
|
96 | - $this->input = $input; |
|
97 | - $this->number = $number; |
|
98 | - $this->phone = $phone; |
|
99 | - $this->select = $select; |
|
100 | - $this->text = $text; |
|
101 | - $this->assembleValidTypeOptions(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - private function assembleValidTypeOptions() |
|
106 | - { |
|
107 | - $block = $this->block->validTypeOptions(); |
|
108 | - $button = $this->button->validTypeOptions(); |
|
109 | - $datetime = $this->datetime->validTypeOptions(); |
|
110 | - $input = $this->input->validTypeOptions(); |
|
111 | - $number = $this->number->validTypeOptions(); |
|
112 | - $phone = $this->phone->validTypeOptions(); |
|
113 | - $select = $this->select->validTypeOptions(); |
|
114 | - $text = $this->text->validTypeOptions(); |
|
115 | - $this->valid_type_options = apply_filters( |
|
116 | - 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | - array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getInputTypesValues() |
|
126 | - { |
|
127 | - $values = []; |
|
128 | - foreach ($this->valid_type_options as $value => $description) { |
|
129 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | - } |
|
131 | - return $values; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param bool $constants_only |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public function validTypeOptions($constants_only = false) |
|
140 | - { |
|
141 | - return $constants_only |
|
142 | - ? array_keys($this->valid_type_options) |
|
143 | - : $this->valid_type_options; |
|
144 | - } |
|
25 | + /** |
|
26 | + * @var Block |
|
27 | + */ |
|
28 | + private $block; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Button |
|
32 | + */ |
|
33 | + private $button; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var DateTime |
|
37 | + */ |
|
38 | + private $datetime; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var Input |
|
42 | + */ |
|
43 | + private $input; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var Number |
|
47 | + */ |
|
48 | + private $number; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var Phone |
|
52 | + */ |
|
53 | + private $phone; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var Select |
|
57 | + */ |
|
58 | + private $select; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var Text |
|
62 | + */ |
|
63 | + private $text; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $valid_type_options; |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * InputTypes constructor. |
|
73 | + * |
|
74 | + * @param Block $block |
|
75 | + * @param Button $button |
|
76 | + * @param DateTime $datetime |
|
77 | + * @param Input $input |
|
78 | + * @param Number $number |
|
79 | + * @param Phone $phone |
|
80 | + * @param Select $select |
|
81 | + * @param Text $text |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + Block $block, |
|
85 | + Button $button, |
|
86 | + DateTime $datetime, |
|
87 | + Input $input, |
|
88 | + Number $number, |
|
89 | + Phone $phone, |
|
90 | + Select $select, |
|
91 | + Text $text |
|
92 | + ) { |
|
93 | + $this->block = $block; |
|
94 | + $this->button = $button; |
|
95 | + $this->datetime = $datetime; |
|
96 | + $this->input = $input; |
|
97 | + $this->number = $number; |
|
98 | + $this->phone = $phone; |
|
99 | + $this->select = $select; |
|
100 | + $this->text = $text; |
|
101 | + $this->assembleValidTypeOptions(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + private function assembleValidTypeOptions() |
|
106 | + { |
|
107 | + $block = $this->block->validTypeOptions(); |
|
108 | + $button = $this->button->validTypeOptions(); |
|
109 | + $datetime = $this->datetime->validTypeOptions(); |
|
110 | + $input = $this->input->validTypeOptions(); |
|
111 | + $number = $this->number->validTypeOptions(); |
|
112 | + $phone = $this->phone->validTypeOptions(); |
|
113 | + $select = $this->select->validTypeOptions(); |
|
114 | + $text = $this->text->validTypeOptions(); |
|
115 | + $this->valid_type_options = apply_filters( |
|
116 | + 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | + array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function getInputTypesValues() |
|
126 | + { |
|
127 | + $values = []; |
|
128 | + foreach ($this->valid_type_options as $value => $description) { |
|
129 | + $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | + } |
|
131 | + return $values; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param bool $constants_only |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public function validTypeOptions($constants_only = false) |
|
140 | + { |
|
141 | + return $constants_only |
|
142 | + ? array_keys($this->valid_type_options) |
|
143 | + : $this->valid_type_options; |
|
144 | + } |
|
145 | 145 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function __construct($url) |
53 | 53 | { |
54 | - if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | + if ( ! filter_var($url, FILTER_VALIDATE_URL)) { |
|
55 | 55 | throw new InvalidArgumentException( |
56 | 56 | esc_html__( |
57 | 57 | 'Invalid URL. Both the "Scheme" and "Host" are required.', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | private function setScheme($url) |
87 | 87 | { |
88 | - $this->scheme = $url['scheme'] . '://'; |
|
88 | + $this->scheme = $url['scheme'].'://'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function queryString() |
141 | 141 | { |
142 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | + return $this->query !== '' ? '?'.$this->query : ''; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function fragment() |
174 | 174 | { |
175 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | + return $this->fragment !== '' ? '#'.$this->fragment : ''; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function getFullUrl() |
195 | 195 | { |
196 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | + return $this->scheme().$this->host().$this->path().$this->queryString().$this->fragment(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 |
@@ -16,194 +16,194 @@ |
||
16 | 16 | */ |
17 | 17 | class Url |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $scheme |
|
21 | - */ |
|
22 | - private $scheme; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $host |
|
26 | - */ |
|
27 | - private $host; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $path |
|
31 | - */ |
|
32 | - private $path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $query |
|
36 | - */ |
|
37 | - private $query; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $fragment |
|
41 | - */ |
|
42 | - private $fragment; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Url constructor. |
|
47 | - * |
|
48 | - * @param $url |
|
49 | - * @throws InvalidArgumentException |
|
50 | - */ |
|
51 | - public function __construct($url) |
|
52 | - { |
|
53 | - if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | - throw new InvalidArgumentException( |
|
55 | - esc_html__( |
|
56 | - 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
57 | - 'event_espresso' |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
61 | - $url = parse_url($url); |
|
62 | - $this->setScheme($url); |
|
63 | - $this->setHost($url); |
|
64 | - $this->setPath($url); |
|
65 | - $this->setQuery($url); |
|
66 | - $this->setFragment($url); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
72 | - * will return a string like: 'abc://' |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function scheme() |
|
77 | - { |
|
78 | - return $this->scheme; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @param array $url |
|
84 | - */ |
|
85 | - private function setScheme($url) |
|
86 | - { |
|
87 | - $this->scheme = $url['scheme'] . '://'; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
93 | - * will return a string like: 'example.com' |
|
94 | - * |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function host() |
|
98 | - { |
|
99 | - return $this->host; |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @param array $url |
|
105 | - */ |
|
106 | - private function setHost($url) |
|
107 | - { |
|
108 | - $this->host = $url['host']; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
114 | - * will return a string like: '/path/data' |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function path() |
|
119 | - { |
|
120 | - return $this->path; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param array $url |
|
126 | - */ |
|
127 | - private function setPath($url) |
|
128 | - { |
|
129 | - $this->path = isset($url['path']) ? $url['path'] : ''; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
135 | - * will return a string like: '?key=value' |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function queryString() |
|
140 | - { |
|
141 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
147 | - * will return an array like: array('key' => 'value') |
|
148 | - * |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - public function queryParams() |
|
152 | - { |
|
153 | - return wp_parse_args($this->query); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param array $url |
|
159 | - */ |
|
160 | - private function setQuery($url) |
|
161 | - { |
|
162 | - $this->query = isset($url['query']) ? $url['query'] : ''; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
168 | - * will return a string like: '#id' |
|
169 | - * |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function fragment() |
|
173 | - { |
|
174 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @param array $url |
|
180 | - */ |
|
181 | - private function setFragment($url) |
|
182 | - { |
|
183 | - $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
189 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function getFullUrl() |
|
194 | - { |
|
195 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
201 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
202 | - * |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function __toString() |
|
206 | - { |
|
207 | - return $this->getFullUrl(); |
|
208 | - } |
|
19 | + /** |
|
20 | + * @var string $scheme |
|
21 | + */ |
|
22 | + private $scheme; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $host |
|
26 | + */ |
|
27 | + private $host; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $path |
|
31 | + */ |
|
32 | + private $path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $query |
|
36 | + */ |
|
37 | + private $query; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $fragment |
|
41 | + */ |
|
42 | + private $fragment; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Url constructor. |
|
47 | + * |
|
48 | + * @param $url |
|
49 | + * @throws InvalidArgumentException |
|
50 | + */ |
|
51 | + public function __construct($url) |
|
52 | + { |
|
53 | + if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | + throw new InvalidArgumentException( |
|
55 | + esc_html__( |
|
56 | + 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
57 | + 'event_espresso' |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | + $url = parse_url($url); |
|
62 | + $this->setScheme($url); |
|
63 | + $this->setHost($url); |
|
64 | + $this->setPath($url); |
|
65 | + $this->setQuery($url); |
|
66 | + $this->setFragment($url); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
72 | + * will return a string like: 'abc://' |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function scheme() |
|
77 | + { |
|
78 | + return $this->scheme; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @param array $url |
|
84 | + */ |
|
85 | + private function setScheme($url) |
|
86 | + { |
|
87 | + $this->scheme = $url['scheme'] . '://'; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
93 | + * will return a string like: 'example.com' |
|
94 | + * |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function host() |
|
98 | + { |
|
99 | + return $this->host; |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @param array $url |
|
105 | + */ |
|
106 | + private function setHost($url) |
|
107 | + { |
|
108 | + $this->host = $url['host']; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
114 | + * will return a string like: '/path/data' |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function path() |
|
119 | + { |
|
120 | + return $this->path; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param array $url |
|
126 | + */ |
|
127 | + private function setPath($url) |
|
128 | + { |
|
129 | + $this->path = isset($url['path']) ? $url['path'] : ''; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
135 | + * will return a string like: '?key=value' |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function queryString() |
|
140 | + { |
|
141 | + return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
147 | + * will return an array like: array('key' => 'value') |
|
148 | + * |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + public function queryParams() |
|
152 | + { |
|
153 | + return wp_parse_args($this->query); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param array $url |
|
159 | + */ |
|
160 | + private function setQuery($url) |
|
161 | + { |
|
162 | + $this->query = isset($url['query']) ? $url['query'] : ''; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
168 | + * will return a string like: '#id' |
|
169 | + * |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function fragment() |
|
173 | + { |
|
174 | + return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @param array $url |
|
180 | + */ |
|
181 | + private function setFragment($url) |
|
182 | + { |
|
183 | + $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
189 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function getFullUrl() |
|
194 | + { |
|
195 | + return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
201 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
202 | + * |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function __toString() |
|
206 | + { |
|
207 | + return $this->getFullUrl(); |
|
208 | + } |
|
209 | 209 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | + $this->setName($this->namespace.'ElementTypeEnum'); |
|
26 | 26 | $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class ElementTypeEnum extends EnumBase |
18 | 18 | { |
19 | - /** |
|
20 | - * ElementTypeEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | - $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * ElementTypeEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | + $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - protected function getValues() |
|
34 | - { |
|
35 | - /** @var InputTypes $input_types */ |
|
36 | - $input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes'); |
|
37 | - return $input_types->getInputTypesValues(); |
|
38 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + protected function getValues() |
|
34 | + { |
|
35 | + /** @var InputTypes $input_types */ |
|
36 | + $input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes'); |
|
37 | + return $input_types->getInputTypesValues(); |
|
38 | + } |
|
39 | 39 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | + $this->setName($this->namespace.'FormStatusEnum'); |
|
26 | 26 | $this->setDescription(esc_html__( |
27 | 27 | 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
28 | 28 | 'event_espresso' |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | class FormStatusEnum extends EnumBase |
18 | 18 | { |
19 | - /** |
|
20 | - * FormStatusEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | - $this->setDescription(esc_html__( |
|
26 | - 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
|
27 | - 'event_espresso' |
|
28 | - )); |
|
29 | - parent::__construct(); |
|
30 | - } |
|
19 | + /** |
|
20 | + * FormStatusEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | + $this->setDescription(esc_html__( |
|
26 | + 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
|
27 | + 'event_espresso' |
|
28 | + )); |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - protected function getValues() |
|
37 | - { |
|
38 | - /** @var FormStatus $form_status */ |
|
39 | - $form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus'); |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + protected function getValues() |
|
37 | + { |
|
38 | + /** @var FormStatus $form_status */ |
|
39 | + $form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus'); |
|
40 | 40 | |
41 | - return $form_status->getFormStatusValues(); |
|
42 | - } |
|
41 | + return $form_status->getFormStatusValues(); |
|
42 | + } |
|
43 | 43 | } |