@@ -11,136 +11,136 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Register_Model_Extensions implements EEI_Plugin_API |
13 | 13 | { |
14 | - protected static $_registry; |
|
14 | + protected static $_registry; |
|
15 | 15 | |
16 | - protected static $_extensions = []; |
|
16 | + protected static $_extensions = []; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * register method for setting up model extensions |
|
21 | - * |
|
22 | - * @param string $addon_name unique id for the extensions being setup |
|
23 | - * @param array $setup_args { |
|
24 | - * @return bool |
|
25 | - * @throws EE_Error |
|
26 | - * @type array $model_extension_paths array of folders containing DB model extensions, where each file follows |
|
27 | - * the models naming convention, which is: |
|
28 | - * EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. |
|
29 | - * Where {your_plugin_slug} is really anything you want (but something having |
|
30 | - * to do with your addon, like 'Calendar' or '3D_View') and |
|
31 | - * model_name_extended} is the model extended. |
|
32 | - * The class contained in teh file should extend |
|
33 | - * EEME_Base_{model_name_extended}.model_ext.php. |
|
34 | - * Where {your_plugin_slug} is really anything you want (but something |
|
35 | - * having to do with your addon, like 'Calendar' or '3D_View') and |
|
36 | - * {model_name_extended} is the model extended. The class contained in teh |
|
37 | - * file should extend EEME_Base |
|
38 | - * @type array $class_extension_paths array of folders containing DB class extensions, where each file follows |
|
39 | - * the model class extension naming convention, which is: |
|
40 | - * EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. |
|
41 | - * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
42 | - * and model_name_extended} is the name of the model extended, eg |
|
43 | - * 'Attendee','Event',etc. |
|
44 | - * The class contained in the file should extend EEE_Base_Class |
|
45 | - * ._{model_name_extended}.class_ext.php. |
|
46 | - * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
47 | - * and {model_name_extended} is the name of the model extended, eg |
|
48 | - * 'Attendee','Event',etc. The class contained in the file should extend |
|
49 | - * EEE_Base_Class. |
|
50 | - * } |
|
51 | - * |
|
52 | - */ |
|
53 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
54 | - { |
|
55 | - // required fields MUST be present, so let's make sure they are. |
|
56 | - if ( |
|
57 | - empty($addon_name) |
|
58 | - || ! is_array($setup_args) |
|
59 | - || ( |
|
60 | - empty($setup_args['model_extension_paths']) |
|
61 | - && empty($setup_args['class_extension_paths']) |
|
62 | - ) |
|
63 | - ) { |
|
64 | - throw new EE_Error( |
|
65 | - __( |
|
66 | - 'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', |
|
67 | - 'event_espresso' |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
19 | + /** |
|
20 | + * register method for setting up model extensions |
|
21 | + * |
|
22 | + * @param string $addon_name unique id for the extensions being setup |
|
23 | + * @param array $setup_args { |
|
24 | + * @return bool |
|
25 | + * @throws EE_Error |
|
26 | + * @type array $model_extension_paths array of folders containing DB model extensions, where each file follows |
|
27 | + * the models naming convention, which is: |
|
28 | + * EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. |
|
29 | + * Where {your_plugin_slug} is really anything you want (but something having |
|
30 | + * to do with your addon, like 'Calendar' or '3D_View') and |
|
31 | + * model_name_extended} is the model extended. |
|
32 | + * The class contained in teh file should extend |
|
33 | + * EEME_Base_{model_name_extended}.model_ext.php. |
|
34 | + * Where {your_plugin_slug} is really anything you want (but something |
|
35 | + * having to do with your addon, like 'Calendar' or '3D_View') and |
|
36 | + * {model_name_extended} is the model extended. The class contained in teh |
|
37 | + * file should extend EEME_Base |
|
38 | + * @type array $class_extension_paths array of folders containing DB class extensions, where each file follows |
|
39 | + * the model class extension naming convention, which is: |
|
40 | + * EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. |
|
41 | + * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
42 | + * and model_name_extended} is the name of the model extended, eg |
|
43 | + * 'Attendee','Event',etc. |
|
44 | + * The class contained in the file should extend EEE_Base_Class |
|
45 | + * ._{model_name_extended}.class_ext.php. |
|
46 | + * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
47 | + * and {model_name_extended} is the name of the model extended, eg |
|
48 | + * 'Attendee','Event',etc. The class contained in the file should extend |
|
49 | + * EEE_Base_Class. |
|
50 | + * } |
|
51 | + * |
|
52 | + */ |
|
53 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
54 | + { |
|
55 | + // required fields MUST be present, so let's make sure they are. |
|
56 | + if ( |
|
57 | + empty($addon_name) |
|
58 | + || ! is_array($setup_args) |
|
59 | + || ( |
|
60 | + empty($setup_args['model_extension_paths']) |
|
61 | + && empty($setup_args['class_extension_paths']) |
|
62 | + ) |
|
63 | + ) { |
|
64 | + throw new EE_Error( |
|
65 | + __( |
|
66 | + 'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', |
|
67 | + 'event_espresso' |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - // make sure we don't register twice |
|
73 | - if (isset(self::$_registry[ $addon_name ])) { |
|
74 | - return true; |
|
75 | - } |
|
76 | - // check correct loading |
|
77 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
78 | - EE_Error::doing_it_wrong( |
|
79 | - __METHOD__, |
|
80 | - sprintf( |
|
81 | - __( |
|
82 | - 'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s', |
|
83 | - 'event_espresso' |
|
84 | - ), |
|
85 | - $addon_name, |
|
86 | - '<br />', |
|
87 | - did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done', |
|
88 | - did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done' |
|
89 | - ), |
|
90 | - '4.3' |
|
91 | - ); |
|
92 | - } |
|
72 | + // make sure we don't register twice |
|
73 | + if (isset(self::$_registry[ $addon_name ])) { |
|
74 | + return true; |
|
75 | + } |
|
76 | + // check correct loading |
|
77 | + if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
78 | + EE_Error::doing_it_wrong( |
|
79 | + __METHOD__, |
|
80 | + sprintf( |
|
81 | + __( |
|
82 | + 'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s', |
|
83 | + 'event_espresso' |
|
84 | + ), |
|
85 | + $addon_name, |
|
86 | + '<br />', |
|
87 | + did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done', |
|
88 | + did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done' |
|
89 | + ), |
|
90 | + '4.3' |
|
91 | + ); |
|
92 | + } |
|
93 | 93 | |
94 | - self::$_registry[ $addon_name ] = $setup_args; |
|
95 | - self::$_extensions[ $addon_name ] = []; |
|
94 | + self::$_registry[ $addon_name ] = $setup_args; |
|
95 | + self::$_extensions[ $addon_name ] = []; |
|
96 | 96 | |
97 | - if (isset($setup_args['model_extension_paths'])) { |
|
98 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
99 | - $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
|
100 | - // remove all files that are not PHP |
|
101 | - foreach ($class_to_filepath_map as $class => $path) { |
|
102 | - if (substr($path, strlen($path) - 3) !== 'php') { |
|
103 | - unset($class_to_filepath_map[ $class ]); |
|
104 | - } |
|
105 | - } |
|
106 | - EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
107 | - foreach (array_keys($class_to_filepath_map) as $classname) { |
|
108 | - self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname(); |
|
109 | - } |
|
110 | - unset($setup_args['model_extension_paths']); |
|
111 | - } |
|
112 | - if (isset($setup_args['class_extension_paths'])) { |
|
113 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
114 | - $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
|
115 | - EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
116 | - foreach (array_keys($class_to_filepath_map) as $classname) { |
|
117 | - self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname(); |
|
118 | - } |
|
119 | - unset($setup_args['class_extension_paths']); |
|
120 | - } |
|
121 | - foreach ($setup_args as $unknown_key => $unknown_config) { |
|
122 | - throw new EE_Error( |
|
123 | - sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key) |
|
124 | - ); |
|
125 | - } |
|
126 | - return true; |
|
127 | - } |
|
97 | + if (isset($setup_args['model_extension_paths'])) { |
|
98 | + require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
99 | + $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
|
100 | + // remove all files that are not PHP |
|
101 | + foreach ($class_to_filepath_map as $class => $path) { |
|
102 | + if (substr($path, strlen($path) - 3) !== 'php') { |
|
103 | + unset($class_to_filepath_map[ $class ]); |
|
104 | + } |
|
105 | + } |
|
106 | + EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
107 | + foreach (array_keys($class_to_filepath_map) as $classname) { |
|
108 | + self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname(); |
|
109 | + } |
|
110 | + unset($setup_args['model_extension_paths']); |
|
111 | + } |
|
112 | + if (isset($setup_args['class_extension_paths'])) { |
|
113 | + require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
114 | + $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
|
115 | + EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
116 | + foreach (array_keys($class_to_filepath_map) as $classname) { |
|
117 | + self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname(); |
|
118 | + } |
|
119 | + unset($setup_args['class_extension_paths']); |
|
120 | + } |
|
121 | + foreach ($setup_args as $unknown_key => $unknown_config) { |
|
122 | + throw new EE_Error( |
|
123 | + sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key) |
|
124 | + ); |
|
125 | + } |
|
126 | + return true; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * deregister |
|
132 | - * |
|
133 | - * @param string $addon_name |
|
134 | - */ |
|
135 | - public static function deregister(string $addon_name = '') |
|
136 | - { |
|
137 | - if (isset(self::$_registry[ $addon_name ])) { |
|
138 | - unset(self::$_registry[ $addon_name ]); |
|
139 | - foreach (self::$_extensions[ $addon_name ] as $extension_of_type) { |
|
140 | - foreach ($extension_of_type as $extension) { |
|
141 | - $extension->deregister(); |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
130 | + /** |
|
131 | + * deregister |
|
132 | + * |
|
133 | + * @param string $addon_name |
|
134 | + */ |
|
135 | + public static function deregister(string $addon_name = '') |
|
136 | + { |
|
137 | + if (isset(self::$_registry[ $addon_name ])) { |
|
138 | + unset(self::$_registry[ $addon_name ]); |
|
139 | + foreach (self::$_extensions[ $addon_name ] as $extension_of_type) { |
|
140 | + foreach ($extension_of_type as $extension) { |
|
141 | + $extension->deregister(); |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | 146 | } |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | // make sure we don't register twice |
73 | - if (isset(self::$_registry[ $addon_name ])) { |
|
73 | + if (isset(self::$_registry[$addon_name])) { |
|
74 | 74 | return true; |
75 | 75 | } |
76 | 76 | // check correct loading |
77 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
77 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
78 | 78 | EE_Error::doing_it_wrong( |
79 | 79 | __METHOD__, |
80 | 80 | sprintf( |
@@ -91,30 +91,30 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - self::$_registry[ $addon_name ] = $setup_args; |
|
95 | - self::$_extensions[ $addon_name ] = []; |
|
94 | + self::$_registry[$addon_name] = $setup_args; |
|
95 | + self::$_extensions[$addon_name] = []; |
|
96 | 96 | |
97 | 97 | if (isset($setup_args['model_extension_paths'])) { |
98 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
98 | + require_once(EE_LIBRARIES.'plugin_api/db/EEME_Base.lib.php'); |
|
99 | 99 | $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
100 | 100 | // remove all files that are not PHP |
101 | 101 | foreach ($class_to_filepath_map as $class => $path) { |
102 | 102 | if (substr($path, strlen($path) - 3) !== 'php') { |
103 | - unset($class_to_filepath_map[ $class ]); |
|
103 | + unset($class_to_filepath_map[$class]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | EEH_Autoloader::register_autoloader($class_to_filepath_map); |
107 | 107 | foreach (array_keys($class_to_filepath_map) as $classname) { |
108 | - self::$_extensions[ $addon_name ]['models'][ $classname ] = new $classname(); |
|
108 | + self::$_extensions[$addon_name]['models'][$classname] = new $classname(); |
|
109 | 109 | } |
110 | 110 | unset($setup_args['model_extension_paths']); |
111 | 111 | } |
112 | 112 | if (isset($setup_args['class_extension_paths'])) { |
113 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
113 | + require_once(EE_LIBRARIES.'plugin_api/db/EEE_Base_Class.lib.php'); |
|
114 | 114 | $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
115 | 115 | EEH_Autoloader::register_autoloader($class_to_filepath_map); |
116 | 116 | foreach (array_keys($class_to_filepath_map) as $classname) { |
117 | - self::$_extensions[ $addon_name ]['classes'][ $classname ] = new $classname(); |
|
117 | + self::$_extensions[$addon_name]['classes'][$classname] = new $classname(); |
|
118 | 118 | } |
119 | 119 | unset($setup_args['class_extension_paths']); |
120 | 120 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function deregister(string $addon_name = '') |
136 | 136 | { |
137 | - if (isset(self::$_registry[ $addon_name ])) { |
|
138 | - unset(self::$_registry[ $addon_name ]); |
|
139 | - foreach (self::$_extensions[ $addon_name ] as $extension_of_type) { |
|
137 | + if (isset(self::$_registry[$addon_name])) { |
|
138 | + unset(self::$_registry[$addon_name]); |
|
139 | + foreach (self::$_extensions[$addon_name] as $extension_of_type) { |
|
140 | 140 | foreach ($extension_of_type as $extension) { |
141 | 141 | $extension->deregister(); |
142 | 142 | } |
@@ -25,87 +25,87 @@ |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param int $eventId |
|
30 | - * @return array |
|
31 | - * @throws EE_Error |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - public function getData(int $eventId): array |
|
35 | - { |
|
36 | - /** @var EE_Event $event */ |
|
37 | - $event = EEM_Event::instance()->get_one_by_ID($eventId); |
|
38 | - $topLevelSectionId = $event->registrationFormUuid(); |
|
28 | + /** |
|
29 | + * @param int $eventId |
|
30 | + * @return array |
|
31 | + * @throws EE_Error |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + public function getData(int $eventId): array |
|
35 | + { |
|
36 | + /** @var EE_Event $event */ |
|
37 | + $event = EEM_Event::instance()->get_one_by_ID($eventId); |
|
38 | + $topLevelSectionId = $event->registrationFormUuid(); |
|
39 | 39 | |
40 | - /** @var EE_Form_Section[] $form_sections */ |
|
41 | - $form_sections = EEM_Form_Section::instance()->get_all([ |
|
42 | - [ |
|
43 | - 'OR' => [ |
|
44 | - 'FSC_UUID' => $topLevelSectionId, // top level form |
|
45 | - 'FSC_belongsTo' => $topLevelSectionId, // child form sections |
|
46 | - 'FSC_status' => FormStatus::SHARED, // shared form sections |
|
47 | - ] |
|
48 | - ], |
|
49 | - 'order_by' => ['FSC_order' => 'ASC'], |
|
50 | - ]); |
|
40 | + /** @var EE_Form_Section[] $form_sections */ |
|
41 | + $form_sections = EEM_Form_Section::instance()->get_all([ |
|
42 | + [ |
|
43 | + 'OR' => [ |
|
44 | + 'FSC_UUID' => $topLevelSectionId, // top level form |
|
45 | + 'FSC_belongsTo' => $topLevelSectionId, // child form sections |
|
46 | + 'FSC_status' => FormStatus::SHARED, // shared form sections |
|
47 | + ] |
|
48 | + ], |
|
49 | + 'order_by' => ['FSC_order' => 'ASC'], |
|
50 | + ]); |
|
51 | 51 | |
52 | - $sections = []; |
|
53 | - foreach ($form_sections as $section) { |
|
54 | - if ($section instanceof EE_Form_Section) { |
|
55 | - $UUID = $section->UUID(); |
|
52 | + $sections = []; |
|
53 | + foreach ($form_sections as $section) { |
|
54 | + if ($section instanceof EE_Form_Section) { |
|
55 | + $UUID = $section->UUID(); |
|
56 | 56 | |
57 | - // Avoid duplicates, if any |
|
58 | - $sections[ $UUID ] = [ |
|
59 | - 'id' => $UUID, |
|
60 | - 'appliesTo' => GQLUtils::formatEnumKey($section->appliesTo()), |
|
61 | - 'attributes' => $section->attributes()->toJson(), |
|
62 | - 'belongsTo' => $section->belongsTo(), |
|
63 | - 'isActive' => $section->isActive(), |
|
64 | - 'isArchived' => $section->isArchived(), |
|
65 | - 'isDefault' => $section->isDefault(), |
|
66 | - 'isShared' => $section->isShared(), |
|
67 | - 'isTrashed' => $section->isTrashed(), |
|
68 | - 'label' => $section->label()->toJson(), |
|
69 | - 'order' => $section->order(), |
|
70 | - 'status' => GQLUtils::formatEnumKey($section->status()), |
|
71 | - ]; |
|
72 | - } |
|
73 | - } |
|
57 | + // Avoid duplicates, if any |
|
58 | + $sections[ $UUID ] = [ |
|
59 | + 'id' => $UUID, |
|
60 | + 'appliesTo' => GQLUtils::formatEnumKey($section->appliesTo()), |
|
61 | + 'attributes' => $section->attributes()->toJson(), |
|
62 | + 'belongsTo' => $section->belongsTo(), |
|
63 | + 'isActive' => $section->isActive(), |
|
64 | + 'isArchived' => $section->isArchived(), |
|
65 | + 'isDefault' => $section->isDefault(), |
|
66 | + 'isShared' => $section->isShared(), |
|
67 | + 'isTrashed' => $section->isTrashed(), |
|
68 | + 'label' => $section->label()->toJson(), |
|
69 | + 'order' => $section->order(), |
|
70 | + 'status' => GQLUtils::formatEnumKey($section->status()), |
|
71 | + ]; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** @var EE_Form_Element[] $form_elements */ |
|
76 | - $form_elements = EEM_Form_Element::instance()->get_all([ |
|
77 | - [ |
|
78 | - 'FSC_UUID' => ['IN', array_keys($sections)] |
|
79 | - ] |
|
80 | - ]); |
|
75 | + /** @var EE_Form_Element[] $form_elements */ |
|
76 | + $form_elements = EEM_Form_Element::instance()->get_all([ |
|
77 | + [ |
|
78 | + 'FSC_UUID' => ['IN', array_keys($sections)] |
|
79 | + ] |
|
80 | + ]); |
|
81 | 81 | |
82 | - $elements = []; |
|
83 | - foreach ($form_elements as $element) { |
|
84 | - if ($element instanceof EE_Form_Element) { |
|
85 | - $UUID = $element->UUID(); |
|
82 | + $elements = []; |
|
83 | + foreach ($form_elements as $element) { |
|
84 | + if ($element instanceof EE_Form_Element) { |
|
85 | + $UUID = $element->UUID(); |
|
86 | 86 | |
87 | - // Avoid duplicates |
|
88 | - $elements[ $UUID ] = [ |
|
89 | - 'id' => $UUID, |
|
90 | - 'adminOnly' => $element->adminOnly(), |
|
91 | - 'attributes' => $element->attributes()->toJson(), |
|
92 | - 'belongsTo' => $element->belongsTo(), |
|
93 | - 'helpText' => $element->helpText()->toJson(), |
|
94 | - 'label' => $element->label()->toJson(), |
|
95 | - 'mapsTo' => $element->mapsTo(), |
|
96 | - 'options' => $element->options()->toJson(), |
|
97 | - 'order' => $element->order(), |
|
98 | - 'required' => $element->required()->toJson(), |
|
99 | - 'status' => GQLUtils::formatEnumKey($element->status()), |
|
100 | - 'type' => GQLUtils::formatEnumKey($element->type()), |
|
101 | - ]; |
|
102 | - } |
|
103 | - } |
|
87 | + // Avoid duplicates |
|
88 | + $elements[ $UUID ] = [ |
|
89 | + 'id' => $UUID, |
|
90 | + 'adminOnly' => $element->adminOnly(), |
|
91 | + 'attributes' => $element->attributes()->toJson(), |
|
92 | + 'belongsTo' => $element->belongsTo(), |
|
93 | + 'helpText' => $element->helpText()->toJson(), |
|
94 | + 'label' => $element->label()->toJson(), |
|
95 | + 'mapsTo' => $element->mapsTo(), |
|
96 | + 'options' => $element->options()->toJson(), |
|
97 | + 'order' => $element->order(), |
|
98 | + 'required' => $element->required()->toJson(), |
|
99 | + 'status' => GQLUtils::formatEnumKey($element->status()), |
|
100 | + 'type' => GQLUtils::formatEnumKey($element->type()), |
|
101 | + ]; |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - return [ |
|
106 | - 'elements' => array_values($elements), |
|
107 | - 'sections' => array_values($sections), |
|
108 | - 'topLevelSectionId' => $event->registrationFormUuid() |
|
109 | - ]; |
|
110 | - } |
|
105 | + return [ |
|
106 | + 'elements' => array_values($elements), |
|
107 | + 'sections' => array_values($sections), |
|
108 | + 'topLevelSectionId' => $event->registrationFormUuid() |
|
109 | + ]; |
|
110 | + } |
|
111 | 111 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $UUID = $section->UUID(); |
56 | 56 | |
57 | 57 | // Avoid duplicates, if any |
58 | - $sections[ $UUID ] = [ |
|
58 | + $sections[$UUID] = [ |
|
59 | 59 | 'id' => $UUID, |
60 | 60 | 'appliesTo' => GQLUtils::formatEnumKey($section->appliesTo()), |
61 | 61 | 'attributes' => $section->attributes()->toJson(), |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $UUID = $element->UUID(); |
86 | 86 | |
87 | 87 | // Avoid duplicates |
88 | - $elements[ $UUID ] = [ |
|
88 | + $elements[$UUID] = [ |
|
89 | 89 | 'id' => $UUID, |
90 | 90 | 'adminOnly' => $element->adminOnly(), |
91 | 91 | 'attributes' => $element->attributes()->toJson(), |
@@ -4,61 +4,61 @@ |
||
4 | 4 | |
5 | 5 | class Text |
6 | 6 | { |
7 | - /** |
|
8 | - * indicates that the HTML input type is 'email' |
|
9 | - */ |
|
10 | - public const TYPE_EMAIL = 'email'; |
|
7 | + /** |
|
8 | + * indicates that the HTML input type is 'email' |
|
9 | + */ |
|
10 | + public const TYPE_EMAIL = 'email'; |
|
11 | 11 | |
12 | - /** |
|
13 | - * indicates that the input is used to confirm an email address |
|
14 | - */ |
|
15 | - public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation'; |
|
12 | + /** |
|
13 | + * indicates that the input is used to confirm an email address |
|
14 | + */ |
|
15 | + public const TYPE_EMAIL_CONFIRMATION = 'email-confirmation'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * indicates that the HTML input type is 'text' |
|
19 | - */ |
|
20 | - public const TYPE_TEXT = 'text'; |
|
17 | + /** |
|
18 | + * indicates that the HTML input type is 'text' |
|
19 | + */ |
|
20 | + public const TYPE_TEXT = 'text'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that the input is a TEXTAREA that only allows plain text |
|
24 | - */ |
|
25 | - public const TYPE_TEXTAREA = 'textarea'; |
|
22 | + /** |
|
23 | + * indicates that the input is a TEXTAREA that only allows plain text |
|
24 | + */ |
|
25 | + public const TYPE_TEXTAREA = 'textarea'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * indicates that the input is a TEXTAREA that allows simple html |
|
29 | - */ |
|
30 | - public const TYPE_TEXTAREA_HTML = 'textarea-html'; |
|
27 | + /** |
|
28 | + * indicates that the input is a TEXTAREA that allows simple html |
|
29 | + */ |
|
30 | + public const TYPE_TEXTAREA_HTML = 'textarea-html'; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - private $valid_type_options; |
|
33 | + /** |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + private $valid_type_options; |
|
37 | 37 | |
38 | 38 | |
39 | - public function __construct() |
|
40 | - { |
|
41 | - $this->valid_type_options = apply_filters( |
|
42 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options', |
|
43 | - [ |
|
44 | - Text::TYPE_EMAIL => esc_html__('Email', 'event_espresso'), |
|
45 | - Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'), |
|
46 | - Text::TYPE_TEXT => esc_html__('Plain Text', 'event_espresso'), |
|
47 | - Text::TYPE_TEXTAREA => esc_html__('Plain Textarea', 'event_espresso'), |
|
48 | - Text::TYPE_TEXTAREA_HTML => esc_html__('Simple HTML Textarea', 'event_espresso'), |
|
49 | - ] |
|
50 | - ); |
|
51 | - } |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + $this->valid_type_options = apply_filters( |
|
42 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Text__valid_type_options', |
|
43 | + [ |
|
44 | + Text::TYPE_EMAIL => esc_html__('Email', 'event_espresso'), |
|
45 | + Text::TYPE_EMAIL_CONFIRMATION => esc_html__('Email Confirmation', 'event_espresso'), |
|
46 | + Text::TYPE_TEXT => esc_html__('Plain Text', 'event_espresso'), |
|
47 | + Text::TYPE_TEXTAREA => esc_html__('Plain Textarea', 'event_espresso'), |
|
48 | + Text::TYPE_TEXTAREA_HTML => esc_html__('Simple HTML Textarea', 'event_espresso'), |
|
49 | + ] |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @param bool $constants_only |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function validTypeOptions(bool $constants_only = false): array |
|
59 | - { |
|
60 | - return $constants_only |
|
61 | - ? array_keys($this->valid_type_options) |
|
62 | - : $this->valid_type_options; |
|
63 | - } |
|
54 | + /** |
|
55 | + * @param bool $constants_only |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function validTypeOptions(bool $constants_only = false): array |
|
59 | + { |
|
60 | + return $constants_only |
|
61 | + ? array_keys($this->valid_type_options) |
|
62 | + : $this->valid_type_options; |
|
63 | + } |
|
64 | 64 | } |
@@ -5,90 +5,90 @@ |
||
5 | 5 | class Input |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * indicates that the HTML input type is 'checkbox' |
|
10 | - */ |
|
11 | - public const TYPE_CHECKBOX = 'checkbox'; |
|
12 | - |
|
13 | - /** |
|
14 | - * indicates that the HTML input type is 'multi checkbox' |
|
15 | - */ |
|
16 | - public const TYPE_CHECKBOX_MULTI = 'checkbox-multi'; |
|
17 | - |
|
18 | - /** |
|
19 | - * indicates that the HTML input type is 'color' |
|
20 | - */ |
|
21 | - public const TYPE_COLOR = 'color'; |
|
22 | - |
|
23 | - /** |
|
24 | - * indicates that the HTML input type is 'file' |
|
25 | - */ |
|
26 | - public const TYPE_FILE = 'file'; |
|
27 | - |
|
28 | - /** |
|
29 | - * indicates that the HTML input type is 'hidden' |
|
30 | - */ |
|
31 | - public const TYPE_HIDDEN = 'hidden'; |
|
32 | - |
|
33 | - /** |
|
34 | - * indicates that the HTML input type is 'image' |
|
35 | - */ |
|
36 | - public const TYPE_IMAGE = 'image'; |
|
37 | - |
|
38 | - /** |
|
39 | - * indicates that the HTML input type is 'password' |
|
40 | - */ |
|
41 | - public const TYPE_PASSWORD = 'password'; |
|
42 | - |
|
43 | - /** |
|
44 | - * indicates that the input is used to confirm a password |
|
45 | - */ |
|
46 | - public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation'; |
|
47 | - |
|
48 | - /** |
|
49 | - * indicates that the HTML input type is 'radio' |
|
50 | - */ |
|
51 | - public const TYPE_RADIO = 'radio'; |
|
52 | - |
|
53 | - /** |
|
54 | - * indicates that the HTML input type is 'url' |
|
55 | - */ |
|
56 | - public const TYPE_URL = 'url'; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var array |
|
60 | - */ |
|
61 | - private $valid_type_options; |
|
62 | - |
|
63 | - |
|
64 | - public function __construct() |
|
65 | - { |
|
66 | - $this->valid_type_options = apply_filters( |
|
67 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options', |
|
68 | - [ |
|
69 | - Input::TYPE_CHECKBOX => esc_html__('Checkbox', 'event_espresso'), |
|
70 | - Input::TYPE_CHECKBOX_MULTI => esc_html__('Multi Checkbox', 'event_espresso'), |
|
71 | - Input::TYPE_COLOR => esc_html__('Color Picker', 'event_espresso'), |
|
72 | - Input::TYPE_FILE => esc_html__('File Upload', 'event_espresso'), |
|
73 | - Input::TYPE_HIDDEN => esc_html__('Hidden', 'event_espresso'), |
|
74 | - Input::TYPE_IMAGE => esc_html__('Image Upload', 'event_espresso'), |
|
75 | - Input::TYPE_PASSWORD => esc_html__('Password', 'event_espresso'), |
|
76 | - Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'), |
|
77 | - Input::TYPE_RADIO => esc_html__('Radio Button', 'event_espresso'), |
|
78 | - Input::TYPE_URL => esc_html__('URL', 'event_espresso'), |
|
79 | - ] |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param bool $constants_only |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - public function validTypeOptions(bool $constants_only = false): array |
|
89 | - { |
|
90 | - return $constants_only |
|
91 | - ? array_keys($this->valid_type_options) |
|
92 | - : $this->valid_type_options; |
|
93 | - } |
|
8 | + /** |
|
9 | + * indicates that the HTML input type is 'checkbox' |
|
10 | + */ |
|
11 | + public const TYPE_CHECKBOX = 'checkbox'; |
|
12 | + |
|
13 | + /** |
|
14 | + * indicates that the HTML input type is 'multi checkbox' |
|
15 | + */ |
|
16 | + public const TYPE_CHECKBOX_MULTI = 'checkbox-multi'; |
|
17 | + |
|
18 | + /** |
|
19 | + * indicates that the HTML input type is 'color' |
|
20 | + */ |
|
21 | + public const TYPE_COLOR = 'color'; |
|
22 | + |
|
23 | + /** |
|
24 | + * indicates that the HTML input type is 'file' |
|
25 | + */ |
|
26 | + public const TYPE_FILE = 'file'; |
|
27 | + |
|
28 | + /** |
|
29 | + * indicates that the HTML input type is 'hidden' |
|
30 | + */ |
|
31 | + public const TYPE_HIDDEN = 'hidden'; |
|
32 | + |
|
33 | + /** |
|
34 | + * indicates that the HTML input type is 'image' |
|
35 | + */ |
|
36 | + public const TYPE_IMAGE = 'image'; |
|
37 | + |
|
38 | + /** |
|
39 | + * indicates that the HTML input type is 'password' |
|
40 | + */ |
|
41 | + public const TYPE_PASSWORD = 'password'; |
|
42 | + |
|
43 | + /** |
|
44 | + * indicates that the input is used to confirm a password |
|
45 | + */ |
|
46 | + public const TYPE_PASSWORD_CONFIRMATION = 'password-confirmation'; |
|
47 | + |
|
48 | + /** |
|
49 | + * indicates that the HTML input type is 'radio' |
|
50 | + */ |
|
51 | + public const TYPE_RADIO = 'radio'; |
|
52 | + |
|
53 | + /** |
|
54 | + * indicates that the HTML input type is 'url' |
|
55 | + */ |
|
56 | + public const TYPE_URL = 'url'; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var array |
|
60 | + */ |
|
61 | + private $valid_type_options; |
|
62 | + |
|
63 | + |
|
64 | + public function __construct() |
|
65 | + { |
|
66 | + $this->valid_type_options = apply_filters( |
|
67 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options', |
|
68 | + [ |
|
69 | + Input::TYPE_CHECKBOX => esc_html__('Checkbox', 'event_espresso'), |
|
70 | + Input::TYPE_CHECKBOX_MULTI => esc_html__('Multi Checkbox', 'event_espresso'), |
|
71 | + Input::TYPE_COLOR => esc_html__('Color Picker', 'event_espresso'), |
|
72 | + Input::TYPE_FILE => esc_html__('File Upload', 'event_espresso'), |
|
73 | + Input::TYPE_HIDDEN => esc_html__('Hidden', 'event_espresso'), |
|
74 | + Input::TYPE_IMAGE => esc_html__('Image Upload', 'event_espresso'), |
|
75 | + Input::TYPE_PASSWORD => esc_html__('Password', 'event_espresso'), |
|
76 | + Input::TYPE_PASSWORD_CONFIRMATION => esc_html__('Password Confirmation', 'event_espresso'), |
|
77 | + Input::TYPE_RADIO => esc_html__('Radio Button', 'event_espresso'), |
|
78 | + Input::TYPE_URL => esc_html__('URL', 'event_espresso'), |
|
79 | + ] |
|
80 | + ); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param bool $constants_only |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + public function validTypeOptions(bool $constants_only = false): array |
|
89 | + { |
|
90 | + return $constants_only |
|
91 | + ? array_keys($this->valid_type_options) |
|
92 | + : $this->valid_type_options; |
|
93 | + } |
|
94 | 94 | } |
@@ -15,173 +15,173 @@ |
||
15 | 15 | class FormLabel implements JsonableInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var JsonDataHandler |
|
20 | - */ |
|
21 | - private $json_data_handler; |
|
22 | - |
|
23 | - /** |
|
24 | - * Input label displayed in the admin to help differentiate input from others |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - private $adminLabel; |
|
29 | - |
|
30 | - /** |
|
31 | - * Input label displayed on public forms, ie: the actual question text. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - private $publicLabel; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var bool |
|
39 | - */ |
|
40 | - private $showLabel; |
|
41 | - |
|
42 | - /** |
|
43 | - * The HTML block displayed for block elements. |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - private $html; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * FormLabel constructor. |
|
52 | - * |
|
53 | - * @param JsonDataHandler $json_data_handler |
|
54 | - * @param string $adminLabel |
|
55 | - * @param string $publicLabel |
|
56 | - * @param bool $showLabel |
|
57 | - */ |
|
58 | - public function __construct( |
|
59 | - JsonDataHandler $json_data_handler, |
|
60 | - string $adminLabel, |
|
61 | - string $publicLabel, |
|
62 | - bool $showLabel, |
|
63 | - string $html |
|
64 | - ) { |
|
65 | - $this->json_data_handler = $json_data_handler; |
|
66 | - $this->setAdminLabel($adminLabel); |
|
67 | - $this->setPublicLabel($publicLabel); |
|
68 | - $this->setShowLabel($showLabel); |
|
69 | - $this->setHtml($html); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param string $json |
|
75 | - * @return FormLabel |
|
76 | - */ |
|
77 | - public static function fromJson(string $json): FormLabel |
|
78 | - { |
|
79 | - $json_data_handler = new JsonDataHandler(); |
|
80 | - $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT); |
|
81 | - $data = $json_data_handler->decodeJson($json); |
|
82 | - $adminLabel = $data->adminLabel ?? ''; |
|
83 | - $publicLabel = $data->publicLabel ?? ''; |
|
84 | - $showLabel = $data->showLabel ?? false; |
|
85 | - $html = $data->html ?? ''; |
|
86 | - return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel, $html); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function toArray(): array |
|
94 | - { |
|
95 | - return [ |
|
96 | - 'adminLabel' => $this->adminLabel, |
|
97 | - 'publicLabel' => $this->publicLabel, |
|
98 | - 'showLabel' => $this->showLabel, |
|
99 | - 'html' => $this->html, |
|
100 | - ]; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function toJson(): string |
|
108 | - { |
|
109 | - return $this->json_data_handler->encodeData($this->toArray()); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Input label displayed in the admin to help differentiate input from others |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function adminLabel(): string |
|
119 | - { |
|
120 | - return $this->adminLabel; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param string $adminLabel |
|
126 | - */ |
|
127 | - public function setAdminLabel(string $adminLabel): void |
|
128 | - { |
|
129 | - $this->adminLabel = sanitize_text_field($adminLabel); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * Input label displayed on public forms, ie: the actual question text. |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - public function publicLabel(): string |
|
139 | - { |
|
140 | - return $this->publicLabel; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param string $publicLabel |
|
146 | - */ |
|
147 | - public function setPublicLabel(string $publicLabel): void |
|
148 | - { |
|
149 | - $this->publicLabel = sanitize_text_field($publicLabel); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return bool |
|
155 | - */ |
|
156 | - public function showLabel(): bool |
|
157 | - { |
|
158 | - return $this->showLabel; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param bool|int|string $showLabel |
|
164 | - */ |
|
165 | - public function setShowLabel($showLabel): void |
|
166 | - { |
|
167 | - $this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public function html(): string |
|
175 | - { |
|
176 | - return $this->html; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string $html |
|
182 | - */ |
|
183 | - public function setHtml(string $html): void |
|
184 | - { |
|
185 | - $this->html = wp_kses_post($html); |
|
186 | - } |
|
18 | + /** |
|
19 | + * @var JsonDataHandler |
|
20 | + */ |
|
21 | + private $json_data_handler; |
|
22 | + |
|
23 | + /** |
|
24 | + * Input label displayed in the admin to help differentiate input from others |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + private $adminLabel; |
|
29 | + |
|
30 | + /** |
|
31 | + * Input label displayed on public forms, ie: the actual question text. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + private $publicLabel; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | + private $showLabel; |
|
41 | + |
|
42 | + /** |
|
43 | + * The HTML block displayed for block elements. |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + private $html; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * FormLabel constructor. |
|
52 | + * |
|
53 | + * @param JsonDataHandler $json_data_handler |
|
54 | + * @param string $adminLabel |
|
55 | + * @param string $publicLabel |
|
56 | + * @param bool $showLabel |
|
57 | + */ |
|
58 | + public function __construct( |
|
59 | + JsonDataHandler $json_data_handler, |
|
60 | + string $adminLabel, |
|
61 | + string $publicLabel, |
|
62 | + bool $showLabel, |
|
63 | + string $html |
|
64 | + ) { |
|
65 | + $this->json_data_handler = $json_data_handler; |
|
66 | + $this->setAdminLabel($adminLabel); |
|
67 | + $this->setPublicLabel($publicLabel); |
|
68 | + $this->setShowLabel($showLabel); |
|
69 | + $this->setHtml($html); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param string $json |
|
75 | + * @return FormLabel |
|
76 | + */ |
|
77 | + public static function fromJson(string $json): FormLabel |
|
78 | + { |
|
79 | + $json_data_handler = new JsonDataHandler(); |
|
80 | + $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT); |
|
81 | + $data = $json_data_handler->decodeJson($json); |
|
82 | + $adminLabel = $data->adminLabel ?? ''; |
|
83 | + $publicLabel = $data->publicLabel ?? ''; |
|
84 | + $showLabel = $data->showLabel ?? false; |
|
85 | + $html = $data->html ?? ''; |
|
86 | + return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel, $html); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function toArray(): array |
|
94 | + { |
|
95 | + return [ |
|
96 | + 'adminLabel' => $this->adminLabel, |
|
97 | + 'publicLabel' => $this->publicLabel, |
|
98 | + 'showLabel' => $this->showLabel, |
|
99 | + 'html' => $this->html, |
|
100 | + ]; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function toJson(): string |
|
108 | + { |
|
109 | + return $this->json_data_handler->encodeData($this->toArray()); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Input label displayed in the admin to help differentiate input from others |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function adminLabel(): string |
|
119 | + { |
|
120 | + return $this->adminLabel; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param string $adminLabel |
|
126 | + */ |
|
127 | + public function setAdminLabel(string $adminLabel): void |
|
128 | + { |
|
129 | + $this->adminLabel = sanitize_text_field($adminLabel); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * Input label displayed on public forms, ie: the actual question text. |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + public function publicLabel(): string |
|
139 | + { |
|
140 | + return $this->publicLabel; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param string $publicLabel |
|
146 | + */ |
|
147 | + public function setPublicLabel(string $publicLabel): void |
|
148 | + { |
|
149 | + $this->publicLabel = sanitize_text_field($publicLabel); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return bool |
|
155 | + */ |
|
156 | + public function showLabel(): bool |
|
157 | + { |
|
158 | + return $this->showLabel; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param bool|int|string $showLabel |
|
164 | + */ |
|
165 | + public function setShowLabel($showLabel): void |
|
166 | + { |
|
167 | + $this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public function html(): string |
|
175 | + { |
|
176 | + return $this->html; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string $html |
|
182 | + */ |
|
183 | + public function setHtml(string $html): void |
|
184 | + { |
|
185 | + $this->html = wp_kses_post($html); |
|
186 | + } |
|
187 | 187 | } |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | class Venues extends GraphQLData |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $where_params |
|
18 | - * @return array|null |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function getData(array $where_params = []) |
|
22 | - { |
|
23 | - $field_key = lcfirst($this->namespace) . 'Venues'; |
|
24 | - $query = <<<QUERY |
|
16 | + /** |
|
17 | + * @param array $where_params |
|
18 | + * @return array|null |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function getData(array $where_params = []) |
|
22 | + { |
|
23 | + $field_key = lcfirst($this->namespace) . 'Venues'; |
|
24 | + $query = <<<QUERY |
|
25 | 25 | query GET_VENUES(\$where: RootQueryTo{$this->namespace}VenueConnectionWhereArgs, \$first: Int, \$last: Int ) { |
26 | 26 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
27 | 27 | nodes { |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | QUERY; |
44 | - $this->setParams([ |
|
45 | - 'operation_name' => 'GET_VENUES', |
|
46 | - 'variables' => [ |
|
47 | - 'first' => 100, |
|
48 | - ], |
|
49 | - 'query' => $query, |
|
50 | - ]); |
|
44 | + $this->setParams([ |
|
45 | + 'operation_name' => 'GET_VENUES', |
|
46 | + 'variables' => [ |
|
47 | + 'first' => 100, |
|
48 | + ], |
|
49 | + 'query' => $query, |
|
50 | + ]); |
|
51 | 51 | |
52 | - return $this->getQueryResponse($field_key, $where_params); |
|
53 | - } |
|
52 | + return $this->getQueryResponse($field_key, $where_params); |
|
53 | + } |
|
54 | 54 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function getData(array $where_params = []) |
22 | 22 | { |
23 | - $field_key = lcfirst($this->namespace) . 'Venues'; |
|
23 | + $field_key = lcfirst($this->namespace).'Venues'; |
|
24 | 24 | $query = <<<QUERY |
25 | 25 | query GET_VENUES(\$where: RootQueryTo{$this->namespace}VenueConnectionWhereArgs, \$first: Int, \$last: Int ) { |
26 | 26 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -18,128 +18,128 @@ |
||
18 | 18 | class EspressoEventEditor extends EspressoEventsAdmin |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * returns true if the current request matches this route |
|
23 | - * |
|
24 | - * @return bool |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function matchesCurrentRequest(): bool |
|
28 | - { |
|
29 | - return parent::matchesCurrentRequest() |
|
30 | - && $this->admin_config->useAdvancedEditor() |
|
31 | - && ( |
|
32 | - $this->request->getRequestParam('action') === 'create_new' |
|
33 | - || $this->request->getRequestParam('action') === 'edit' |
|
34 | - ); |
|
35 | - } |
|
21 | + /** |
|
22 | + * returns true if the current request matches this route |
|
23 | + * |
|
24 | + * @return bool |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function matchesCurrentRequest(): bool |
|
28 | + { |
|
29 | + return parent::matchesCurrentRequest() |
|
30 | + && $this->admin_config->useAdvancedEditor() |
|
31 | + && ( |
|
32 | + $this->request->getRequestParam('action') === 'create_new' |
|
33 | + || $this->request->getRequestParam('action') === 'edit' |
|
34 | + ); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - protected function registerDependencies() |
|
42 | - { |
|
43 | - $editor_dependencies = [ |
|
44 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
45 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
46 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Event' => EE_Dependency_Map::load_from_cache, |
|
47 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
48 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
49 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
50 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
51 | - '\EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => EE_Dependency_Map::load_from_cache, |
|
52 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | - 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => EE_Dependency_Map::load_from_cache, |
|
54 | - 'EventEspresso\core\domain\services\admin\events\editor\FormBuilder' => EE_Dependency_Map::load_from_cache, |
|
55 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Venues' => EE_Dependency_Map::load_from_cache, |
|
56 | - ], |
|
57 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
58 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
64 | - ], |
|
65 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
66 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
67 | - 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => EE_Dependency_Map::load_from_cache, |
|
68 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
74 | - ], |
|
75 | - 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => [ |
|
76 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
77 | - ], |
|
78 | - 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => [ |
|
79 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | - ], |
|
82 | - 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => [ |
|
83 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
84 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
85 | - ], |
|
86 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => [ |
|
87 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
88 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
89 | - ], |
|
90 | - 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => [ |
|
91 | - 'EEM_Form_Element' => EE_Dependency_Map::load_from_cache, |
|
92 | - 'EEM_Form_Section' => EE_Dependency_Map::load_from_cache, |
|
93 | - ], |
|
94 | - 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' => [ |
|
95 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
96 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
97 | - ], |
|
98 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' => [ |
|
99 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
100 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
101 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
102 | - ], |
|
103 | - 'EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => [ |
|
104 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
105 | - 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
106 | - ], |
|
107 | - ]; |
|
108 | - foreach ($editor_dependencies as $dependency => $dependencies) { |
|
109 | - $this->dependency_map->registerDependencies($dependency, $dependencies); |
|
110 | - } |
|
111 | - } |
|
38 | + /** |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + protected function registerDependencies() |
|
42 | + { |
|
43 | + $editor_dependencies = [ |
|
44 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
45 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
46 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Event' => EE_Dependency_Map::load_from_cache, |
|
47 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
48 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
49 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
50 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
51 | + '\EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => EE_Dependency_Map::load_from_cache, |
|
52 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
53 | + 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => EE_Dependency_Map::load_from_cache, |
|
54 | + 'EventEspresso\core\domain\services\admin\events\editor\FormBuilder' => EE_Dependency_Map::load_from_cache, |
|
55 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Venues' => EE_Dependency_Map::load_from_cache, |
|
56 | + ], |
|
57 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
58 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
59 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
60 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
61 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
62 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
63 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
64 | + ], |
|
65 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
66 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache, |
|
67 | + 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => EE_Dependency_Map::load_from_cache, |
|
68 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
69 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
70 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
71 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
72 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
73 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
74 | + ], |
|
75 | + 'EventEspresso\core\domain\services\admin\events\editor\TicketMeta' => [ |
|
76 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
77 | + ], |
|
78 | + 'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => [ |
|
79 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache, |
|
80 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
81 | + ], |
|
82 | + 'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => [ |
|
83 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache, |
|
84 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
85 | + ], |
|
86 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => [ |
|
87 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
88 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
89 | + ], |
|
90 | + 'EventEspresso\core\domain\services\admin\entities\DefaultFormSections' => [ |
|
91 | + 'EEM_Form_Element' => EE_Dependency_Map::load_from_cache, |
|
92 | + 'EEM_Form_Section' => EE_Dependency_Map::load_from_cache, |
|
93 | + ], |
|
94 | + 'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor' => [ |
|
95 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache, |
|
96 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
97 | + ], |
|
98 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' => [ |
|
99 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
100 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
101 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
102 | + ], |
|
103 | + 'EventEspresso\core\domain\services\admin\events\editor\EventManagerData' => [ |
|
104 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
105 | + 'EventEspresso\core\domain\services\graphql\Utilities' => EE_Dependency_Map::load_from_cache, |
|
106 | + ], |
|
107 | + ]; |
|
108 | + foreach ($editor_dependencies as $dependency => $dependencies) { |
|
109 | + $this->dependency_map->registerDependencies($dependency, $dependencies); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - protected function dataNodeClass(): string |
|
118 | - { |
|
119 | - return EventEditor::class; |
|
120 | - } |
|
114 | + /** |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + protected function dataNodeClass(): string |
|
118 | + { |
|
119 | + return EventEditor::class; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * implements logic required to run during request |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - * @since $VID:$ |
|
128 | - */ |
|
129 | - protected function requestHandler(): bool |
|
130 | - { |
|
131 | - if (! class_exists('WPGraphQL')) { |
|
132 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | - } |
|
134 | - /** @var GraphQLManager $graphQL_manager */ |
|
135 | - $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | - $graphQL_manager->init(); |
|
123 | + /** |
|
124 | + * implements logic required to run during request |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + * @since $VID:$ |
|
128 | + */ |
|
129 | + protected function requestHandler(): bool |
|
130 | + { |
|
131 | + if (! class_exists('WPGraphQL')) { |
|
132 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
133 | + } |
|
134 | + /** @var GraphQLManager $graphQL_manager */ |
|
135 | + $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager'); |
|
136 | + $graphQL_manager->init(); |
|
137 | 137 | |
138 | - /** @var EventEditorAssetManager $asset_manager */ |
|
139 | - $asset_manager = $this->loader->getShared( |
|
140 | - 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | - ); |
|
142 | - add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | - return true; |
|
144 | - } |
|
138 | + /** @var EventEditorAssetManager $asset_manager */ |
|
139 | + $asset_manager = $this->loader->getShared( |
|
140 | + 'EventEspresso\core\domain\services\assets\EventEditorAssetManager' |
|
141 | + ); |
|
142 | + add_action('admin_enqueue_scripts', [$asset_manager, 'enqueueEventEditor']); |
|
143 | + return true; |
|
144 | + } |
|
145 | 145 | } |
@@ -22,150 +22,150 @@ |
||
22 | 22 | class EventEditorGraphQLData |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var Event |
|
27 | - */ |
|
28 | - protected $event; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Datetimes |
|
32 | - */ |
|
33 | - protected $datetimes; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var Prices |
|
37 | - */ |
|
38 | - protected $prices; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var PriceTypes |
|
42 | - */ |
|
43 | - protected $price_types; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var Tickets |
|
47 | - */ |
|
48 | - protected $tickets; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var EventEntityRelations |
|
52 | - */ |
|
53 | - protected $relations; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EventManagerData |
|
57 | - */ |
|
58 | - protected $managers; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var NewEventDefaultEntities |
|
62 | - */ |
|
63 | - protected $default_entities; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var TicketMeta |
|
67 | - */ |
|
68 | - protected $ticket_meta; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var FormBuilder |
|
72 | - */ |
|
73 | - protected $form_builder; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var Venues |
|
77 | - */ |
|
78 | - protected $venues; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * EventEditorGraphQLData constructor. |
|
83 | - * |
|
84 | - * @param Datetimes $datetimes |
|
85 | - * @param Event $event |
|
86 | - * @param Prices $prices |
|
87 | - * @param PriceTypes $price_types |
|
88 | - * @param Tickets $tickets |
|
89 | - * @param EventEntityRelations $relations |
|
90 | - * @param EventManagerData $managers |
|
91 | - * @param NewEventDefaultEntities $default_entities |
|
92 | - * @param TicketMeta $ticket_meta |
|
93 | - * @param FormBuilder $form_builder |
|
94 | - * @param Venues $venues |
|
95 | - */ |
|
96 | - public function __construct( |
|
97 | - Datetimes $datetimes, |
|
98 | - Event $event, |
|
99 | - Prices $prices, |
|
100 | - PriceTypes $price_types, |
|
101 | - Tickets $tickets, |
|
102 | - EventEntityRelations $relations, |
|
103 | - EventManagerData $managers, |
|
104 | - NewEventDefaultEntities $default_entities, |
|
105 | - TicketMeta $ticket_meta, |
|
106 | - FormBuilder $form_builder, |
|
107 | - Venues $venues |
|
108 | - ) { |
|
109 | - $this->datetimes = $datetimes; |
|
110 | - $this->event = $event; |
|
111 | - $this->default_entities = $default_entities; |
|
112 | - $this->prices = $prices; |
|
113 | - $this->price_types = $price_types; |
|
114 | - $this->managers = $managers; |
|
115 | - $this->relations = $relations; |
|
116 | - $this->tickets = $tickets; |
|
117 | - $this->ticket_meta = $ticket_meta; |
|
118 | - $this->form_builder = $form_builder; |
|
119 | - $this->venues = $venues; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @param int $eventId |
|
125 | - * @return array |
|
126 | - * @throws EE_Error |
|
127 | - * @throws ReflectionException |
|
128 | - * @since $VID:$ |
|
129 | - */ |
|
130 | - public function getData(int $eventId) |
|
131 | - { |
|
132 | - $this->default_entities->getData($eventId); |
|
133 | - $event = $this->event->getData(['id' => $eventId]); |
|
134 | - $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
135 | - $eventManagers = $this->managers ->getData($eventId); |
|
136 | - |
|
137 | - $tickets = $this->tickets->getData([ |
|
138 | - 'eventId' => $eventId, |
|
139 | - 'includeDefaultTickets' => true, |
|
140 | - ]); |
|
141 | - |
|
142 | - $prices = $this->prices->getData([ |
|
143 | - 'eventId' => $eventId, |
|
144 | - 'includeDefaultTicketsPrices' => true, |
|
145 | - 'includeDefaultPrices' => true, |
|
146 | - ]); |
|
147 | - |
|
148 | - $priceTypes = $this->price_types->getData(); |
|
149 | - |
|
150 | - $relations = $this->relations->getData($eventId); |
|
151 | - |
|
152 | - $ticketMeta = $this->ticket_meta->getData($eventId); |
|
153 | - |
|
154 | - $formBuilder = $this->form_builder->getData($eventId); |
|
155 | - |
|
156 | - $venues = $this->venues->getData(); |
|
157 | - |
|
158 | - return compact( |
|
159 | - 'datetimes', |
|
160 | - 'event', |
|
161 | - 'eventManagers', |
|
162 | - 'formBuilder', |
|
163 | - 'prices', |
|
164 | - 'priceTypes', |
|
165 | - 'relations', |
|
166 | - 'tickets', |
|
167 | - 'ticketMeta', |
|
168 | - 'venues' |
|
169 | - ); |
|
170 | - } |
|
25 | + /** |
|
26 | + * @var Event |
|
27 | + */ |
|
28 | + protected $event; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Datetimes |
|
32 | + */ |
|
33 | + protected $datetimes; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var Prices |
|
37 | + */ |
|
38 | + protected $prices; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var PriceTypes |
|
42 | + */ |
|
43 | + protected $price_types; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var Tickets |
|
47 | + */ |
|
48 | + protected $tickets; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var EventEntityRelations |
|
52 | + */ |
|
53 | + protected $relations; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EventManagerData |
|
57 | + */ |
|
58 | + protected $managers; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var NewEventDefaultEntities |
|
62 | + */ |
|
63 | + protected $default_entities; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var TicketMeta |
|
67 | + */ |
|
68 | + protected $ticket_meta; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var FormBuilder |
|
72 | + */ |
|
73 | + protected $form_builder; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var Venues |
|
77 | + */ |
|
78 | + protected $venues; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * EventEditorGraphQLData constructor. |
|
83 | + * |
|
84 | + * @param Datetimes $datetimes |
|
85 | + * @param Event $event |
|
86 | + * @param Prices $prices |
|
87 | + * @param PriceTypes $price_types |
|
88 | + * @param Tickets $tickets |
|
89 | + * @param EventEntityRelations $relations |
|
90 | + * @param EventManagerData $managers |
|
91 | + * @param NewEventDefaultEntities $default_entities |
|
92 | + * @param TicketMeta $ticket_meta |
|
93 | + * @param FormBuilder $form_builder |
|
94 | + * @param Venues $venues |
|
95 | + */ |
|
96 | + public function __construct( |
|
97 | + Datetimes $datetimes, |
|
98 | + Event $event, |
|
99 | + Prices $prices, |
|
100 | + PriceTypes $price_types, |
|
101 | + Tickets $tickets, |
|
102 | + EventEntityRelations $relations, |
|
103 | + EventManagerData $managers, |
|
104 | + NewEventDefaultEntities $default_entities, |
|
105 | + TicketMeta $ticket_meta, |
|
106 | + FormBuilder $form_builder, |
|
107 | + Venues $venues |
|
108 | + ) { |
|
109 | + $this->datetimes = $datetimes; |
|
110 | + $this->event = $event; |
|
111 | + $this->default_entities = $default_entities; |
|
112 | + $this->prices = $prices; |
|
113 | + $this->price_types = $price_types; |
|
114 | + $this->managers = $managers; |
|
115 | + $this->relations = $relations; |
|
116 | + $this->tickets = $tickets; |
|
117 | + $this->ticket_meta = $ticket_meta; |
|
118 | + $this->form_builder = $form_builder; |
|
119 | + $this->venues = $venues; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @param int $eventId |
|
125 | + * @return array |
|
126 | + * @throws EE_Error |
|
127 | + * @throws ReflectionException |
|
128 | + * @since $VID:$ |
|
129 | + */ |
|
130 | + public function getData(int $eventId) |
|
131 | + { |
|
132 | + $this->default_entities->getData($eventId); |
|
133 | + $event = $this->event->getData(['id' => $eventId]); |
|
134 | + $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
135 | + $eventManagers = $this->managers ->getData($eventId); |
|
136 | + |
|
137 | + $tickets = $this->tickets->getData([ |
|
138 | + 'eventId' => $eventId, |
|
139 | + 'includeDefaultTickets' => true, |
|
140 | + ]); |
|
141 | + |
|
142 | + $prices = $this->prices->getData([ |
|
143 | + 'eventId' => $eventId, |
|
144 | + 'includeDefaultTicketsPrices' => true, |
|
145 | + 'includeDefaultPrices' => true, |
|
146 | + ]); |
|
147 | + |
|
148 | + $priceTypes = $this->price_types->getData(); |
|
149 | + |
|
150 | + $relations = $this->relations->getData($eventId); |
|
151 | + |
|
152 | + $ticketMeta = $this->ticket_meta->getData($eventId); |
|
153 | + |
|
154 | + $formBuilder = $this->form_builder->getData($eventId); |
|
155 | + |
|
156 | + $venues = $this->venues->getData(); |
|
157 | + |
|
158 | + return compact( |
|
159 | + 'datetimes', |
|
160 | + 'event', |
|
161 | + 'eventManagers', |
|
162 | + 'formBuilder', |
|
163 | + 'prices', |
|
164 | + 'priceTypes', |
|
165 | + 'relations', |
|
166 | + 'tickets', |
|
167 | + 'ticketMeta', |
|
168 | + 'venues' |
|
169 | + ); |
|
170 | + } |
|
171 | 171 | } |
@@ -21,114 +21,114 @@ |
||
21 | 21 | class EventMutation |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Maps the GraphQL input to a format that the model functions can use |
|
26 | - * |
|
27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
28 | - * @return array |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - public static function prepareFields(array $input): array |
|
32 | - { |
|
33 | - $args = []; |
|
34 | - |
|
35 | - if (array_key_exists('allowDonations', $input)) { |
|
36 | - $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | - } |
|
38 | - |
|
39 | - if (array_key_exists('allowOverflow', $input)) { |
|
40 | - $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | - } |
|
42 | - |
|
43 | - if (array_key_exists('altRegPage', $input)) { |
|
44 | - $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['defaultRegStatus'])) { |
|
48 | - $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | - } |
|
50 | - |
|
51 | - if (! empty($input['description'])) { |
|
52 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | - } |
|
54 | - |
|
55 | - if (array_key_exists('displayDescription', $input)) { |
|
56 | - $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | - } |
|
58 | - |
|
59 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | - $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | - } |
|
62 | - |
|
63 | - if (! empty($input['maxRegistrations'])) { |
|
64 | - $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | - } |
|
66 | - |
|
67 | - if (array_key_exists('memberOnly', $input)) { |
|
68 | - $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | - } |
|
70 | - |
|
71 | - if (! empty($input['name'])) { |
|
72 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | - } |
|
74 | - |
|
75 | - if (array_key_exists('order', $input)) { |
|
76 | - $args['EVT_order'] = absint($input['order']); |
|
77 | - } |
|
78 | - |
|
79 | - if (array_key_exists('phoneNumber', $input)) { |
|
80 | - $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | - } |
|
82 | - |
|
83 | - if (array_key_exists('shortDescription', $input)) { |
|
84 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | - } |
|
86 | - |
|
87 | - if (array_key_exists('timezoneString', $input)) { |
|
88 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | - } |
|
90 | - |
|
91 | - if (! empty($input['visibleOn'])) { |
|
92 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | - } |
|
94 | - |
|
95 | - if (! empty($input['manager'])) { |
|
96 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | - $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | - } |
|
99 | - |
|
100 | - if (array_key_exists('venue', $input)) { |
|
101 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['venue'])); |
|
102 | - $args['venue'] = ! empty($parts['id']) ? $parts['id'] : 0; |
|
103 | - } |
|
104 | - |
|
105 | - return apply_filters( |
|
106 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
107 | - $args, |
|
108 | - $input |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Sets the venue for the event. |
|
115 | - * |
|
116 | - * @param EE_Event $entity The event instance. |
|
117 | - * @param int $venue The venue ID |
|
118 | - * @throws EE_Error |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - * @throws InvalidArgumentException |
|
122 | - * @throws ReflectionException |
|
123 | - */ |
|
124 | - public static function setEventVenue(EE_Event $entity, int $venue) |
|
125 | - { |
|
126 | - $relationName = 'Venue'; |
|
127 | - // Remove the existing venues |
|
128 | - $entity->_remove_relations($relationName); |
|
129 | - |
|
130 | - if ($venue) { |
|
131 | - $entity->add_venue($venue); |
|
132 | - } |
|
133 | - } |
|
24 | + /** |
|
25 | + * Maps the GraphQL input to a format that the model functions can use |
|
26 | + * |
|
27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
28 | + * @return array |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + public static function prepareFields(array $input): array |
|
32 | + { |
|
33 | + $args = []; |
|
34 | + |
|
35 | + if (array_key_exists('allowDonations', $input)) { |
|
36 | + $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | + } |
|
38 | + |
|
39 | + if (array_key_exists('allowOverflow', $input)) { |
|
40 | + $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | + } |
|
42 | + |
|
43 | + if (array_key_exists('altRegPage', $input)) { |
|
44 | + $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['defaultRegStatus'])) { |
|
48 | + $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | + } |
|
50 | + |
|
51 | + if (! empty($input['description'])) { |
|
52 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | + } |
|
54 | + |
|
55 | + if (array_key_exists('displayDescription', $input)) { |
|
56 | + $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | + } |
|
58 | + |
|
59 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | + $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | + } |
|
62 | + |
|
63 | + if (! empty($input['maxRegistrations'])) { |
|
64 | + $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | + } |
|
66 | + |
|
67 | + if (array_key_exists('memberOnly', $input)) { |
|
68 | + $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | + } |
|
70 | + |
|
71 | + if (! empty($input['name'])) { |
|
72 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | + } |
|
74 | + |
|
75 | + if (array_key_exists('order', $input)) { |
|
76 | + $args['EVT_order'] = absint($input['order']); |
|
77 | + } |
|
78 | + |
|
79 | + if (array_key_exists('phoneNumber', $input)) { |
|
80 | + $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | + } |
|
82 | + |
|
83 | + if (array_key_exists('shortDescription', $input)) { |
|
84 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | + } |
|
86 | + |
|
87 | + if (array_key_exists('timezoneString', $input)) { |
|
88 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | + } |
|
90 | + |
|
91 | + if (! empty($input['visibleOn'])) { |
|
92 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | + } |
|
94 | + |
|
95 | + if (! empty($input['manager'])) { |
|
96 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | + $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | + } |
|
99 | + |
|
100 | + if (array_key_exists('venue', $input)) { |
|
101 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['venue'])); |
|
102 | + $args['venue'] = ! empty($parts['id']) ? $parts['id'] : 0; |
|
103 | + } |
|
104 | + |
|
105 | + return apply_filters( |
|
106 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
107 | + $args, |
|
108 | + $input |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Sets the venue for the event. |
|
115 | + * |
|
116 | + * @param EE_Event $entity The event instance. |
|
117 | + * @param int $venue The venue ID |
|
118 | + * @throws EE_Error |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + * @throws InvalidArgumentException |
|
122 | + * @throws ReflectionException |
|
123 | + */ |
|
124 | + public static function setEventVenue(EE_Event $entity, int $venue) |
|
125 | + { |
|
126 | + $relationName = 'Venue'; |
|
127 | + // Remove the existing venues |
|
128 | + $entity->_remove_relations($relationName); |
|
129 | + |
|
130 | + if ($venue) { |
|
131 | + $entity->add_venue($venue); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['defaultRegStatus'])) { |
|
47 | + if ( ! empty($input['defaultRegStatus'])) { |
|
48 | 48 | $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['description'])) { |
|
51 | + if ( ! empty($input['description'])) { |
|
52 | 52 | $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
53 | 53 | } |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
61 | 61 | } |
62 | 62 | |
63 | - if (! empty($input['maxRegistrations'])) { |
|
63 | + if ( ! empty($input['maxRegistrations'])) { |
|
64 | 64 | $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
65 | 65 | } |
66 | 66 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
69 | 69 | } |
70 | 70 | |
71 | - if (! empty($input['name'])) { |
|
71 | + if ( ! empty($input['name'])) { |
|
72 | 72 | $args['EVT_name'] = sanitize_text_field($input['name']); |
73 | 73 | } |
74 | 74 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
89 | 89 | } |
90 | 90 | |
91 | - if (! empty($input['visibleOn'])) { |
|
91 | + if ( ! empty($input['visibleOn'])) { |
|
92 | 92 | $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
93 | 93 | } |
94 | 94 | |
95 | - if (! empty($input['manager'])) { |
|
95 | + if ( ! empty($input['manager'])) { |
|
96 | 96 | $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
97 | 97 | $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
98 | 98 | } |