@@ -11,30 +11,30 @@ |
||
11 | 11 | class GraphQLInputField extends GraphQLField |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $name |
|
16 | - * @param string|string[] $type |
|
17 | - * @param string|null $key |
|
18 | - * @param string $description |
|
19 | - * @param array $caps |
|
20 | - */ |
|
21 | - public function __construct( |
|
22 | - $name, |
|
23 | - $type, |
|
24 | - $key = null, |
|
25 | - $description = '', |
|
26 | - array $caps = [] |
|
27 | - ) { |
|
28 | - parent::__construct( |
|
29 | - $name, |
|
30 | - $type, |
|
31 | - $key, |
|
32 | - $description, |
|
33 | - null, |
|
34 | - null, |
|
35 | - $caps |
|
36 | - ); |
|
14 | + /** |
|
15 | + * @param string $name |
|
16 | + * @param string|string[] $type |
|
17 | + * @param string|null $key |
|
18 | + * @param string $description |
|
19 | + * @param array $caps |
|
20 | + */ |
|
21 | + public function __construct( |
|
22 | + $name, |
|
23 | + $type, |
|
24 | + $key = null, |
|
25 | + $description = '', |
|
26 | + array $caps = [] |
|
27 | + ) { |
|
28 | + parent::__construct( |
|
29 | + $name, |
|
30 | + $type, |
|
31 | + $key, |
|
32 | + $description, |
|
33 | + null, |
|
34 | + null, |
|
35 | + $caps |
|
36 | + ); |
|
37 | 37 | |
38 | - $this->setUseForOutput(false); |
|
39 | - } |
|
38 | + $this->setUseForOutput(false); |
|
39 | + } |
|
40 | 40 | } |
@@ -11,34 +11,34 @@ |
||
11 | 11 | class GraphQLOutputField extends GraphQLField |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param string $name |
|
16 | - * @param string|string[] $type |
|
17 | - * @param string|null $key |
|
18 | - * @param string $description |
|
19 | - * @param callable|null $formatter |
|
20 | - * @param callable|null $resolver |
|
21 | - * @param array $caps |
|
22 | - */ |
|
23 | - public function __construct( |
|
24 | - $name, |
|
25 | - $type, |
|
26 | - $key = null, |
|
27 | - $description = '', |
|
28 | - callable $formatter = null, |
|
29 | - callable $resolver = null, |
|
30 | - array $caps = [] |
|
31 | - ) { |
|
32 | - parent::__construct( |
|
33 | - $name, |
|
34 | - $type, |
|
35 | - $key, |
|
36 | - $description, |
|
37 | - $formatter, |
|
38 | - $resolver, |
|
39 | - $caps |
|
40 | - ); |
|
14 | + /** |
|
15 | + * @param string $name |
|
16 | + * @param string|string[] $type |
|
17 | + * @param string|null $key |
|
18 | + * @param string $description |
|
19 | + * @param callable|null $formatter |
|
20 | + * @param callable|null $resolver |
|
21 | + * @param array $caps |
|
22 | + */ |
|
23 | + public function __construct( |
|
24 | + $name, |
|
25 | + $type, |
|
26 | + $key = null, |
|
27 | + $description = '', |
|
28 | + callable $formatter = null, |
|
29 | + callable $resolver = null, |
|
30 | + array $caps = [] |
|
31 | + ) { |
|
32 | + parent::__construct( |
|
33 | + $name, |
|
34 | + $type, |
|
35 | + $key, |
|
36 | + $description, |
|
37 | + $formatter, |
|
38 | + $resolver, |
|
39 | + $caps |
|
40 | + ); |
|
41 | 41 | |
42 | - $this->setUseForInput(false); |
|
43 | - } |
|
42 | + $this->setUseForInput(false); |
|
43 | + } |
|
44 | 44 | } |
@@ -18,40 +18,40 @@ |
||
18 | 18 | class ConnectionsManager |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | - */ |
|
24 | - private $connections; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * ConnectionsManager constructor. |
|
29 | - * |
|
30 | - * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | - */ |
|
32 | - public function __construct(ConnectionCollection $connections) |
|
33 | - { |
|
34 | - $this->connections = $connections; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->connections->loadConnections(); |
|
46 | - add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - public function registerConnections() |
|
51 | - { |
|
52 | - // loop through the collection of types and register their fields |
|
53 | - foreach ($this->connections as $connection) { |
|
54 | - register_graphql_connection($connection->config()); |
|
55 | - } |
|
56 | - } |
|
21 | + /** |
|
22 | + * @var ConnectionCollection|ConnectionInterface[] $connections |
|
23 | + */ |
|
24 | + private $connections; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * ConnectionsManager constructor. |
|
29 | + * |
|
30 | + * @param ConnectionCollection|ConnectionInterface[] $connections |
|
31 | + */ |
|
32 | + public function __construct(ConnectionCollection $connections) |
|
33 | + { |
|
34 | + $this->connections = $connections; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->connections->loadConnections(); |
|
46 | + add_action('graphql_register_types', [$this, 'registerConnections'], 20); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + public function registerConnections() |
|
51 | + { |
|
52 | + // loop through the collection of types and register their fields |
|
53 | + foreach ($this->connections as $connection) { |
|
54 | + register_graphql_connection($connection->config()); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -17,293 +17,293 @@ |
||
17 | 17 | class CustomPostTypeDefinitions |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var EE_Core_Config |
|
22 | - */ |
|
23 | - public $core_config; |
|
20 | + /** |
|
21 | + * @var EE_Core_Config |
|
22 | + */ |
|
23 | + public $core_config; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var array $custom_post_types |
|
27 | - */ |
|
28 | - private $custom_post_types; |
|
25 | + /** |
|
26 | + * @var array $custom_post_types |
|
27 | + */ |
|
28 | + private $custom_post_types; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var LoaderInterface $loader |
|
32 | - */ |
|
33 | - private $loader; |
|
30 | + /** |
|
31 | + * @var LoaderInterface $loader |
|
32 | + */ |
|
33 | + private $loader; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * EspressoCustomPostTypeDefinitions constructor. |
|
38 | - * |
|
39 | - * @param EE_Core_Config $core_config |
|
40 | - * @param LoaderInterface $loader |
|
41 | - */ |
|
42 | - public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
43 | - { |
|
44 | - $this->core_config = $core_config; |
|
45 | - $this->loader = $loader; |
|
46 | - $this->setDefinitions(); |
|
47 | - } |
|
36 | + /** |
|
37 | + * EspressoCustomPostTypeDefinitions constructor. |
|
38 | + * |
|
39 | + * @param EE_Core_Config $core_config |
|
40 | + * @param LoaderInterface $loader |
|
41 | + */ |
|
42 | + public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
43 | + { |
|
44 | + $this->core_config = $core_config; |
|
45 | + $this->loader = $loader; |
|
46 | + $this->setDefinitions(); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * defines Espresso Custom Post Types |
|
52 | - * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
53 | - * and not part of the WP custom post type api. |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - private function setDefinitions() |
|
58 | - { |
|
59 | - $this->custom_post_types = [ |
|
60 | - 'espresso_events' => [ |
|
61 | - 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
62 | - 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
63 | - 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
64 | - 'plural_slug' => $this->core_config->event_cpt_slug, |
|
65 | - 'class_name' => 'EE_Event', |
|
66 | - 'model_name' => 'EEM_Event', |
|
67 | - 'args' => [ |
|
68 | - 'public' => true, |
|
69 | - 'show_in_nav_menus' => true, |
|
70 | - 'show_in_graphql' => true, |
|
71 | - 'graphql_single_name' => __('Event', 'event_espresso'), |
|
72 | - 'graphql_plural_name' => __('Events', 'event_espresso'), |
|
73 | - 'capability_type' => 'event', |
|
74 | - 'capabilities' => [ |
|
75 | - 'edit_post' => 'ee_edit_event', |
|
76 | - 'read_post' => 'ee_read_event', |
|
77 | - 'delete_post' => 'ee_delete_event', |
|
78 | - 'edit_posts' => 'ee_edit_events', |
|
79 | - 'edit_others_posts' => 'ee_edit_others_events', |
|
80 | - 'publish_posts' => 'ee_publish_events', |
|
81 | - 'read_private_posts' => 'ee_read_private_events', |
|
82 | - 'delete_posts' => 'ee_delete_events', |
|
83 | - 'delete_private_posts' => 'ee_delete_private_events', |
|
84 | - 'delete_published_posts' => 'ee_delete_published_events', |
|
85 | - 'delete_others_posts' => 'ee_delete_others_events', |
|
86 | - 'edit_private_posts' => 'ee_edit_private_events', |
|
87 | - 'edit_published_posts' => 'ee_edit_published_events', |
|
88 | - ], |
|
89 | - 'taxonomies' => [ |
|
90 | - 'espresso_event_categories', |
|
91 | - 'espresso_event_type', |
|
92 | - 'post_tag', |
|
93 | - ], |
|
94 | - 'page_templates' => true, |
|
95 | - ], |
|
96 | - ], |
|
97 | - 'espresso_venues' => [ |
|
98 | - 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
99 | - 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
100 | - 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
101 | - 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
102 | - 'class_name' => 'EE_Venue', |
|
103 | - 'model_name' => 'EEM_Venue', |
|
104 | - 'args' => [ |
|
105 | - 'public' => true, |
|
106 | - 'show_in_nav_menus' => false, // by default this doesn't show for decaf, |
|
107 | - 'show_in_graphql' => true, |
|
108 | - 'graphql_single_name' => __('Venue', 'event_espresso'), |
|
109 | - 'graphql_plural_name' => __('Venues', 'event_espresso'), |
|
110 | - 'capability_type' => 'venue', |
|
111 | - 'capabilities' => [ |
|
112 | - 'edit_post' => 'ee_edit_venue', |
|
113 | - 'read_post' => 'ee_read_venue', |
|
114 | - 'delete_post' => 'ee_delete_venue', |
|
115 | - 'edit_posts' => 'ee_edit_venues', |
|
116 | - 'edit_others_posts' => 'ee_edit_others_venues', |
|
117 | - 'publish_posts' => 'ee_publish_venues', |
|
118 | - 'read_private_posts' => 'ee_read_private_venues', |
|
119 | - 'delete_posts' => 'ee_delete_venues', |
|
120 | - 'delete_private_posts' => 'ee_delete_private_venues', |
|
121 | - 'delete_published_posts' => 'ee_delete_published_venues', |
|
122 | - 'delete_others_posts' => 'ee_edit_others_venues', |
|
123 | - 'edit_private_posts' => 'ee_edit_private_venues', |
|
124 | - 'edit_published_posts' => 'ee_edit_published_venues', |
|
125 | - ], |
|
126 | - 'taxonomies' => [ |
|
127 | - 'espresso_venue_categories', |
|
128 | - 'post_tag', |
|
129 | - ], |
|
130 | - 'page_templates' => true, |
|
131 | - ], |
|
132 | - ], |
|
133 | - 'espresso_attendees' => [ |
|
134 | - 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
135 | - 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
136 | - 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
137 | - 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
138 | - 'class_name' => 'EE_Attendee', |
|
139 | - 'model_name' => 'EEM_Attendee', |
|
140 | - 'args' => [ |
|
141 | - 'public' => false, |
|
142 | - 'publicly_queryable' => false, |
|
143 | - 'hierarchical' => false, |
|
144 | - 'has_archive' => false, |
|
145 | - 'supports' => [ |
|
146 | - 'editor', |
|
147 | - 'thumbnail', |
|
148 | - 'excerpt', |
|
149 | - 'custom-fields', |
|
150 | - 'comments', |
|
151 | - ], |
|
152 | - 'taxonomies' => ['post_tag'], |
|
153 | - 'capability_type' => 'contact', |
|
154 | - 'capabilities' => [ |
|
155 | - 'edit_post' => 'ee_edit_contact', |
|
156 | - 'read_post' => 'ee_read_contact', |
|
157 | - 'delete_post' => 'ee_delete_contact', |
|
158 | - 'edit_posts' => 'ee_edit_contacts', |
|
159 | - 'edit_others_posts' => 'ee_edit_contacts', |
|
160 | - 'publish_posts' => 'ee_edit_contacts', |
|
161 | - 'read_private_posts' => 'ee_edit_contacts', |
|
162 | - 'delete_posts' => 'ee_delete_contacts', |
|
163 | - 'delete_private_posts' => 'ee_delete_contacts', |
|
164 | - 'delete_published_posts' => 'ee_delete_contacts', |
|
165 | - 'delete_others_posts' => 'ee_delete_contacts', |
|
166 | - 'edit_private_posts' => 'ee_edit_contacts', |
|
167 | - 'edit_published_posts' => 'ee_edit_contacts', |
|
168 | - ], |
|
169 | - ], |
|
170 | - ], |
|
171 | - ]; |
|
172 | - } |
|
50 | + /** |
|
51 | + * defines Espresso Custom Post Types |
|
52 | + * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
53 | + * and not part of the WP custom post type api. |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + private function setDefinitions() |
|
58 | + { |
|
59 | + $this->custom_post_types = [ |
|
60 | + 'espresso_events' => [ |
|
61 | + 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
62 | + 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
63 | + 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
64 | + 'plural_slug' => $this->core_config->event_cpt_slug, |
|
65 | + 'class_name' => 'EE_Event', |
|
66 | + 'model_name' => 'EEM_Event', |
|
67 | + 'args' => [ |
|
68 | + 'public' => true, |
|
69 | + 'show_in_nav_menus' => true, |
|
70 | + 'show_in_graphql' => true, |
|
71 | + 'graphql_single_name' => __('Event', 'event_espresso'), |
|
72 | + 'graphql_plural_name' => __('Events', 'event_espresso'), |
|
73 | + 'capability_type' => 'event', |
|
74 | + 'capabilities' => [ |
|
75 | + 'edit_post' => 'ee_edit_event', |
|
76 | + 'read_post' => 'ee_read_event', |
|
77 | + 'delete_post' => 'ee_delete_event', |
|
78 | + 'edit_posts' => 'ee_edit_events', |
|
79 | + 'edit_others_posts' => 'ee_edit_others_events', |
|
80 | + 'publish_posts' => 'ee_publish_events', |
|
81 | + 'read_private_posts' => 'ee_read_private_events', |
|
82 | + 'delete_posts' => 'ee_delete_events', |
|
83 | + 'delete_private_posts' => 'ee_delete_private_events', |
|
84 | + 'delete_published_posts' => 'ee_delete_published_events', |
|
85 | + 'delete_others_posts' => 'ee_delete_others_events', |
|
86 | + 'edit_private_posts' => 'ee_edit_private_events', |
|
87 | + 'edit_published_posts' => 'ee_edit_published_events', |
|
88 | + ], |
|
89 | + 'taxonomies' => [ |
|
90 | + 'espresso_event_categories', |
|
91 | + 'espresso_event_type', |
|
92 | + 'post_tag', |
|
93 | + ], |
|
94 | + 'page_templates' => true, |
|
95 | + ], |
|
96 | + ], |
|
97 | + 'espresso_venues' => [ |
|
98 | + 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
99 | + 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
100 | + 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
101 | + 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
102 | + 'class_name' => 'EE_Venue', |
|
103 | + 'model_name' => 'EEM_Venue', |
|
104 | + 'args' => [ |
|
105 | + 'public' => true, |
|
106 | + 'show_in_nav_menus' => false, // by default this doesn't show for decaf, |
|
107 | + 'show_in_graphql' => true, |
|
108 | + 'graphql_single_name' => __('Venue', 'event_espresso'), |
|
109 | + 'graphql_plural_name' => __('Venues', 'event_espresso'), |
|
110 | + 'capability_type' => 'venue', |
|
111 | + 'capabilities' => [ |
|
112 | + 'edit_post' => 'ee_edit_venue', |
|
113 | + 'read_post' => 'ee_read_venue', |
|
114 | + 'delete_post' => 'ee_delete_venue', |
|
115 | + 'edit_posts' => 'ee_edit_venues', |
|
116 | + 'edit_others_posts' => 'ee_edit_others_venues', |
|
117 | + 'publish_posts' => 'ee_publish_venues', |
|
118 | + 'read_private_posts' => 'ee_read_private_venues', |
|
119 | + 'delete_posts' => 'ee_delete_venues', |
|
120 | + 'delete_private_posts' => 'ee_delete_private_venues', |
|
121 | + 'delete_published_posts' => 'ee_delete_published_venues', |
|
122 | + 'delete_others_posts' => 'ee_edit_others_venues', |
|
123 | + 'edit_private_posts' => 'ee_edit_private_venues', |
|
124 | + 'edit_published_posts' => 'ee_edit_published_venues', |
|
125 | + ], |
|
126 | + 'taxonomies' => [ |
|
127 | + 'espresso_venue_categories', |
|
128 | + 'post_tag', |
|
129 | + ], |
|
130 | + 'page_templates' => true, |
|
131 | + ], |
|
132 | + ], |
|
133 | + 'espresso_attendees' => [ |
|
134 | + 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
135 | + 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
136 | + 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
137 | + 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
138 | + 'class_name' => 'EE_Attendee', |
|
139 | + 'model_name' => 'EEM_Attendee', |
|
140 | + 'args' => [ |
|
141 | + 'public' => false, |
|
142 | + 'publicly_queryable' => false, |
|
143 | + 'hierarchical' => false, |
|
144 | + 'has_archive' => false, |
|
145 | + 'supports' => [ |
|
146 | + 'editor', |
|
147 | + 'thumbnail', |
|
148 | + 'excerpt', |
|
149 | + 'custom-fields', |
|
150 | + 'comments', |
|
151 | + ], |
|
152 | + 'taxonomies' => ['post_tag'], |
|
153 | + 'capability_type' => 'contact', |
|
154 | + 'capabilities' => [ |
|
155 | + 'edit_post' => 'ee_edit_contact', |
|
156 | + 'read_post' => 'ee_read_contact', |
|
157 | + 'delete_post' => 'ee_delete_contact', |
|
158 | + 'edit_posts' => 'ee_edit_contacts', |
|
159 | + 'edit_others_posts' => 'ee_edit_contacts', |
|
160 | + 'publish_posts' => 'ee_edit_contacts', |
|
161 | + 'read_private_posts' => 'ee_edit_contacts', |
|
162 | + 'delete_posts' => 'ee_delete_contacts', |
|
163 | + 'delete_private_posts' => 'ee_delete_contacts', |
|
164 | + 'delete_published_posts' => 'ee_delete_contacts', |
|
165 | + 'delete_others_posts' => 'ee_delete_contacts', |
|
166 | + 'edit_private_posts' => 'ee_edit_contacts', |
|
167 | + 'edit_published_posts' => 'ee_edit_contacts', |
|
168 | + ], |
|
169 | + ], |
|
170 | + ], |
|
171 | + ]; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | - /** |
|
176 | - * @return array |
|
177 | - */ |
|
178 | - public function getDefinitions() |
|
179 | - { |
|
180 | - return (array) apply_filters( |
|
181 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
182 | - // legacy filter applied for now, |
|
183 | - // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
184 | - apply_filters( |
|
185 | - 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
186 | - $this->custom_post_types |
|
187 | - ) |
|
188 | - ); |
|
189 | - } |
|
175 | + /** |
|
176 | + * @return array |
|
177 | + */ |
|
178 | + public function getDefinitions() |
|
179 | + { |
|
180 | + return (array) apply_filters( |
|
181 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
182 | + // legacy filter applied for now, |
|
183 | + // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
184 | + apply_filters( |
|
185 | + 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
186 | + $this->custom_post_types |
|
187 | + ) |
|
188 | + ); |
|
189 | + } |
|
190 | 190 | |
191 | 191 | |
192 | - /** |
|
193 | - * @return array |
|
194 | - */ |
|
195 | - public function getCustomPostTypeSlugs() |
|
196 | - { |
|
197 | - return array_keys($this->getDefinitions()); |
|
198 | - } |
|
192 | + /** |
|
193 | + * @return array |
|
194 | + */ |
|
195 | + public function getCustomPostTypeSlugs() |
|
196 | + { |
|
197 | + return array_keys($this->getDefinitions()); |
|
198 | + } |
|
199 | 199 | |
200 | 200 | |
201 | - /** |
|
202 | - * This basically goes through the CPT array and returns only CPT's |
|
203 | - * that have the ['args']['public'] option set as false |
|
204 | - * |
|
205 | - * @return array |
|
206 | - */ |
|
207 | - public function getPrivateCustomPostTypes() |
|
208 | - { |
|
209 | - $private_CPTs = []; |
|
210 | - foreach ($this->getDefinitions() as $CPT => $details) { |
|
211 | - if (empty($details['args']['public'])) { |
|
212 | - $private_CPTs[ $CPT ] = $details; |
|
213 | - } |
|
214 | - } |
|
215 | - return $private_CPTs; |
|
216 | - } |
|
201 | + /** |
|
202 | + * This basically goes through the CPT array and returns only CPT's |
|
203 | + * that have the ['args']['public'] option set as false |
|
204 | + * |
|
205 | + * @return array |
|
206 | + */ |
|
207 | + public function getPrivateCustomPostTypes() |
|
208 | + { |
|
209 | + $private_CPTs = []; |
|
210 | + foreach ($this->getDefinitions() as $CPT => $details) { |
|
211 | + if (empty($details['args']['public'])) { |
|
212 | + $private_CPTs[ $CPT ] = $details; |
|
213 | + } |
|
214 | + } |
|
215 | + return $private_CPTs; |
|
216 | + } |
|
217 | 217 | |
218 | 218 | |
219 | - /** |
|
220 | - * This returns the corresponding model name for cpts registered by EE. |
|
221 | - * |
|
222 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
223 | - * the model name for the given cpt slug. |
|
224 | - * Otherwise if empty, then we'll return |
|
225 | - * all cpt model names for cpts registered in EE. |
|
226 | - * @return array Empty array if no matching model names for the given slug |
|
227 | - * or an array of model names indexed by post type slug. |
|
228 | - */ |
|
229 | - public function getCustomPostTypeModelNames($post_type_slug = '') |
|
230 | - { |
|
231 | - $cpts = $this->getDefinitions(); |
|
232 | - // first if slug passed in... |
|
233 | - if (! empty($post_type_slug)) { |
|
234 | - // check that slug and cpt match |
|
235 | - if (! isset($cpts[ $post_type_slug ])) { |
|
236 | - return []; |
|
237 | - } |
|
238 | - if (empty($cpts[ $post_type_slug ]['class_name']) |
|
239 | - && empty($cpts[ $post_type_slug ]['model_name']) |
|
240 | - ) { |
|
241 | - return []; |
|
242 | - } |
|
243 | - // k let's get the model name for this cpt. |
|
244 | - return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
245 | - } |
|
246 | - // if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
247 | - $cpt_models = []; |
|
248 | - foreach ($cpts as $slug => $args) { |
|
249 | - $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
250 | - if (! empty($model)) { |
|
251 | - $cpt_models[ $slug ] = $model; |
|
252 | - } |
|
253 | - } |
|
254 | - return $cpt_models; |
|
255 | - } |
|
219 | + /** |
|
220 | + * This returns the corresponding model name for cpts registered by EE. |
|
221 | + * |
|
222 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
223 | + * the model name for the given cpt slug. |
|
224 | + * Otherwise if empty, then we'll return |
|
225 | + * all cpt model names for cpts registered in EE. |
|
226 | + * @return array Empty array if no matching model names for the given slug |
|
227 | + * or an array of model names indexed by post type slug. |
|
228 | + */ |
|
229 | + public function getCustomPostTypeModelNames($post_type_slug = '') |
|
230 | + { |
|
231 | + $cpts = $this->getDefinitions(); |
|
232 | + // first if slug passed in... |
|
233 | + if (! empty($post_type_slug)) { |
|
234 | + // check that slug and cpt match |
|
235 | + if (! isset($cpts[ $post_type_slug ])) { |
|
236 | + return []; |
|
237 | + } |
|
238 | + if (empty($cpts[ $post_type_slug ]['class_name']) |
|
239 | + && empty($cpts[ $post_type_slug ]['model_name']) |
|
240 | + ) { |
|
241 | + return []; |
|
242 | + } |
|
243 | + // k let's get the model name for this cpt. |
|
244 | + return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
245 | + } |
|
246 | + // if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
247 | + $cpt_models = []; |
|
248 | + foreach ($cpts as $slug => $args) { |
|
249 | + $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
250 | + if (! empty($model)) { |
|
251 | + $cpt_models[ $slug ] = $model; |
|
252 | + } |
|
253 | + } |
|
254 | + return $cpt_models; |
|
255 | + } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * @param $post_type_slug |
|
260 | - * @param array $cpt |
|
261 | - * @return array |
|
262 | - */ |
|
263 | - private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
264 | - { |
|
265 | - if (! empty($cpt['model_name'])) { |
|
266 | - return [$post_type_slug => $cpt['model_name']]; |
|
267 | - } |
|
268 | - if (! empty($cpt['class_name'])) { |
|
269 | - return [ |
|
270 | - $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']), |
|
271 | - ]; |
|
272 | - } |
|
273 | - return []; |
|
274 | - } |
|
258 | + /** |
|
259 | + * @param $post_type_slug |
|
260 | + * @param array $cpt |
|
261 | + * @return array |
|
262 | + */ |
|
263 | + private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
264 | + { |
|
265 | + if (! empty($cpt['model_name'])) { |
|
266 | + return [$post_type_slug => $cpt['model_name']]; |
|
267 | + } |
|
268 | + if (! empty($cpt['class_name'])) { |
|
269 | + return [ |
|
270 | + $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']), |
|
271 | + ]; |
|
272 | + } |
|
273 | + return []; |
|
274 | + } |
|
275 | 275 | |
276 | 276 | |
277 | - /** |
|
278 | - * @param string $class_name |
|
279 | - * @return string |
|
280 | - */ |
|
281 | - private function deriveCptModelNameFromClassName($class_name) |
|
282 | - { |
|
283 | - return str_replace('EE', 'EEM', $class_name); |
|
284 | - } |
|
277 | + /** |
|
278 | + * @param string $class_name |
|
279 | + * @return string |
|
280 | + */ |
|
281 | + private function deriveCptModelNameFromClassName($class_name) |
|
282 | + { |
|
283 | + return str_replace('EE', 'EEM', $class_name); |
|
284 | + } |
|
285 | 285 | |
286 | 286 | |
287 | - /** |
|
288 | - * This instantiates cpt models related to the cpts registered via EE. |
|
289 | - * |
|
290 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
291 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
292 | - * instantiated (if possible). |
|
293 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
294 | - * EEM models indexed by post slug. |
|
295 | - * @since 4.6.16.rc.000 |
|
296 | - */ |
|
297 | - public function getCustomPostTypeModels($post_type_slug = '') |
|
298 | - { |
|
299 | - $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
300 | - $instantiated = []; |
|
301 | - foreach ($cpt_model_names as $slug => $model_name) { |
|
302 | - $model = $this->loader->getShared($model_name); |
|
303 | - if ($model instanceof EEM_CPT_Base) { |
|
304 | - $instantiated[ $slug ] = $model; |
|
305 | - } |
|
306 | - } |
|
307 | - return $instantiated; |
|
308 | - } |
|
287 | + /** |
|
288 | + * This instantiates cpt models related to the cpts registered via EE. |
|
289 | + * |
|
290 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
291 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
292 | + * instantiated (if possible). |
|
293 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
294 | + * EEM models indexed by post slug. |
|
295 | + * @since 4.6.16.rc.000 |
|
296 | + */ |
|
297 | + public function getCustomPostTypeModels($post_type_slug = '') |
|
298 | + { |
|
299 | + $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
300 | + $instantiated = []; |
|
301 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
302 | + $model = $this->loader->getShared($model_name); |
|
303 | + if ($model instanceof EEM_CPT_Base) { |
|
304 | + $instantiated[ $slug ] = $model; |
|
305 | + } |
|
306 | + } |
|
307 | + return $instantiated; |
|
308 | + } |
|
309 | 309 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $private_CPTs = []; |
210 | 210 | foreach ($this->getDefinitions() as $CPT => $details) { |
211 | 211 | if (empty($details['args']['public'])) { |
212 | - $private_CPTs[ $CPT ] = $details; |
|
212 | + $private_CPTs[$CPT] = $details; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | return $private_CPTs; |
@@ -230,25 +230,25 @@ discard block |
||
230 | 230 | { |
231 | 231 | $cpts = $this->getDefinitions(); |
232 | 232 | // first if slug passed in... |
233 | - if (! empty($post_type_slug)) { |
|
233 | + if ( ! empty($post_type_slug)) { |
|
234 | 234 | // check that slug and cpt match |
235 | - if (! isset($cpts[ $post_type_slug ])) { |
|
235 | + if ( ! isset($cpts[$post_type_slug])) { |
|
236 | 236 | return []; |
237 | 237 | } |
238 | - if (empty($cpts[ $post_type_slug ]['class_name']) |
|
239 | - && empty($cpts[ $post_type_slug ]['model_name']) |
|
238 | + if (empty($cpts[$post_type_slug]['class_name']) |
|
239 | + && empty($cpts[$post_type_slug]['model_name']) |
|
240 | 240 | ) { |
241 | 241 | return []; |
242 | 242 | } |
243 | 243 | // k let's get the model name for this cpt. |
244 | - return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
244 | + return $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]); |
|
245 | 245 | } |
246 | 246 | // if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
247 | 247 | $cpt_models = []; |
248 | 248 | foreach ($cpts as $slug => $args) { |
249 | - $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
250 | - if (! empty($model)) { |
|
251 | - $cpt_models[ $slug ] = $model; |
|
249 | + $model = $this->getCustomPostTypeModelName($post_type_slug, $cpts[$post_type_slug]); |
|
250 | + if ( ! empty($model)) { |
|
251 | + $cpt_models[$slug] = $model; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | return $cpt_models; |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | */ |
263 | 263 | private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
264 | 264 | { |
265 | - if (! empty($cpt['model_name'])) { |
|
265 | + if ( ! empty($cpt['model_name'])) { |
|
266 | 266 | return [$post_type_slug => $cpt['model_name']]; |
267 | 267 | } |
268 | - if (! empty($cpt['class_name'])) { |
|
268 | + if ( ! empty($cpt['class_name'])) { |
|
269 | 269 | return [ |
270 | 270 | $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']), |
271 | 271 | ]; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | foreach ($cpt_model_names as $slug => $model_name) { |
302 | 302 | $model = $this->loader->getShared($model_name); |
303 | 303 | if ($model instanceof EEM_CPT_Base) { |
304 | - $instantiated[ $slug ] = $model; |
|
304 | + $instantiated[$slug] = $model; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | return $instantiated; |
@@ -28,58 +28,58 @@ |
||
28 | 28 | class RestApiSpoofer |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * @var Read |
|
33 | - */ |
|
34 | - protected $rest_api; |
|
31 | + /** |
|
32 | + * @var Read |
|
33 | + */ |
|
34 | + protected $rest_api; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * RestApiSpoofer constructor. |
|
39 | - * |
|
40 | - * @param Read $rest_api |
|
41 | - * @param string $api_version |
|
42 | - */ |
|
43 | - public function __construct(Read $rest_api, $api_version = '4.8.36') |
|
44 | - { |
|
45 | - $this->rest_api = $rest_api; |
|
46 | - $this->rest_api->setRequestedVersion($api_version); |
|
47 | - } |
|
37 | + /** |
|
38 | + * RestApiSpoofer constructor. |
|
39 | + * |
|
40 | + * @param Read $rest_api |
|
41 | + * @param string $api_version |
|
42 | + */ |
|
43 | + public function __construct(Read $rest_api, $api_version = '4.8.36') |
|
44 | + { |
|
45 | + $this->rest_api = $rest_api; |
|
46 | + $this->rest_api->setRequestedVersion($api_version); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param EEM_Base $model |
|
52 | - * @param array $query_params |
|
53 | - * @param string $include |
|
54 | - * @return array |
|
55 | - * @throws EE_Error |
|
56 | - * @throws InvalidArgumentException |
|
57 | - * @throws InvalidDataTypeException |
|
58 | - * @throws InvalidInterfaceException |
|
59 | - * @throws ModelConfigurationException |
|
60 | - * @throws ReflectionException |
|
61 | - * @throws RestException |
|
62 | - * @throws RestPasswordIncorrectException |
|
63 | - * @throws RestPasswordRequiredException |
|
64 | - * @throws UnexpectedEntityException |
|
65 | - * @throws DomainException |
|
66 | - * @since $VID:$ |
|
67 | - */ |
|
68 | - public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
69 | - { |
|
70 | - /** @type array $results */ |
|
71 | - $results = $model->get_all_wpdb_results($query_params); |
|
72 | - $rest_request = new WP_REST_Request(); |
|
73 | - $rest_request->set_param('include', $include); |
|
74 | - $rest_request->set_param('caps', 'edit'); |
|
75 | - $nice_results = array(); |
|
76 | - foreach ($results as $result) { |
|
77 | - $nice_results[] = $this->rest_api->createEntityFromWpdbResult( |
|
78 | - $model, |
|
79 | - $result, |
|
80 | - $rest_request |
|
81 | - ); |
|
82 | - } |
|
83 | - return $nice_results; |
|
84 | - } |
|
50 | + /** |
|
51 | + * @param EEM_Base $model |
|
52 | + * @param array $query_params |
|
53 | + * @param string $include |
|
54 | + * @return array |
|
55 | + * @throws EE_Error |
|
56 | + * @throws InvalidArgumentException |
|
57 | + * @throws InvalidDataTypeException |
|
58 | + * @throws InvalidInterfaceException |
|
59 | + * @throws ModelConfigurationException |
|
60 | + * @throws ReflectionException |
|
61 | + * @throws RestException |
|
62 | + * @throws RestPasswordIncorrectException |
|
63 | + * @throws RestPasswordRequiredException |
|
64 | + * @throws UnexpectedEntityException |
|
65 | + * @throws DomainException |
|
66 | + * @since $VID:$ |
|
67 | + */ |
|
68 | + public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
69 | + { |
|
70 | + /** @type array $results */ |
|
71 | + $results = $model->get_all_wpdb_results($query_params); |
|
72 | + $rest_request = new WP_REST_Request(); |
|
73 | + $rest_request->set_param('include', $include); |
|
74 | + $rest_request->set_param('caps', 'edit'); |
|
75 | + $nice_results = array(); |
|
76 | + foreach ($results as $result) { |
|
77 | + $nice_results[] = $this->rest_api->createEntityFromWpdbResult( |
|
78 | + $model, |
|
79 | + $result, |
|
80 | + $rest_request |
|
81 | + ); |
|
82 | + } |
|
83 | + return $nice_results; |
|
84 | + } |
|
85 | 85 | } |
@@ -22,125 +22,125 @@ |
||
22 | 22 | class DatetimeToJson implements ModelObjectToJsonConverterInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @param EE_Datetime[] $datetimes |
|
27 | - * @return array |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - * @throws ReflectionException |
|
33 | - * @since $VID:$ |
|
34 | - */ |
|
35 | - public function convertAndEncodeArrayOf(array $datetimes) |
|
36 | - { |
|
37 | - $jsonDates = []; |
|
38 | - foreach ($datetimes as $datetime) { |
|
39 | - if ($datetime instanceof EE_Datetime) { |
|
40 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
41 | - } |
|
42 | - } |
|
43 | - return $jsonDates; |
|
44 | - } |
|
25 | + /** |
|
26 | + * @param EE_Datetime[] $datetimes |
|
27 | + * @return array |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + * @throws ReflectionException |
|
33 | + * @since $VID:$ |
|
34 | + */ |
|
35 | + public function convertAndEncodeArrayOf(array $datetimes) |
|
36 | + { |
|
37 | + $jsonDates = []; |
|
38 | + foreach ($datetimes as $datetime) { |
|
39 | + if ($datetime instanceof EE_Datetime) { |
|
40 | + $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
41 | + } |
|
42 | + } |
|
43 | + return $jsonDates; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @param EE_Datetime $datetime |
|
49 | - * @return false|string |
|
50 | - * @throws EE_Error |
|
51 | - * @throws InvalidArgumentException |
|
52 | - * @throws InvalidDataTypeException |
|
53 | - * @throws InvalidInterfaceException |
|
54 | - * @throws ReflectionException |
|
55 | - * @since $VID:$ |
|
56 | - */ |
|
57 | - public function convertAndEncode($datetime) |
|
58 | - { |
|
59 | - return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
60 | - } |
|
47 | + /** |
|
48 | + * @param EE_Datetime $datetime |
|
49 | + * @return false|string |
|
50 | + * @throws EE_Error |
|
51 | + * @throws InvalidArgumentException |
|
52 | + * @throws InvalidDataTypeException |
|
53 | + * @throws InvalidInterfaceException |
|
54 | + * @throws ReflectionException |
|
55 | + * @since $VID:$ |
|
56 | + */ |
|
57 | + public function convertAndEncode($datetime) |
|
58 | + { |
|
59 | + return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @param EE_Datetime[] $datetimes |
|
65 | - * @return array |
|
66 | - * @throws EE_Error |
|
67 | - * @throws InvalidArgumentException |
|
68 | - * @throws InvalidDataTypeException |
|
69 | - * @throws InvalidInterfaceException |
|
70 | - * @throws ReflectionException |
|
71 | - * @since $VID:$ |
|
72 | - */ |
|
73 | - public function convertArrayOf(array $datetimes) |
|
74 | - { |
|
75 | - $arrayOfDates = []; |
|
76 | - foreach ($datetimes as $datetime) { |
|
77 | - if ($datetime instanceof EE_Datetime) { |
|
78 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
79 | - } |
|
80 | - } |
|
81 | - return $arrayOfDates; |
|
82 | - } |
|
63 | + /** |
|
64 | + * @param EE_Datetime[] $datetimes |
|
65 | + * @return array |
|
66 | + * @throws EE_Error |
|
67 | + * @throws InvalidArgumentException |
|
68 | + * @throws InvalidDataTypeException |
|
69 | + * @throws InvalidInterfaceException |
|
70 | + * @throws ReflectionException |
|
71 | + * @since $VID:$ |
|
72 | + */ |
|
73 | + public function convertArrayOf(array $datetimes) |
|
74 | + { |
|
75 | + $arrayOfDates = []; |
|
76 | + foreach ($datetimes as $datetime) { |
|
77 | + if ($datetime instanceof EE_Datetime) { |
|
78 | + $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
79 | + } |
|
80 | + } |
|
81 | + return $arrayOfDates; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @param EE_Datetime $datetime |
|
87 | - * @return array |
|
88 | - * @throws EE_Error |
|
89 | - * @throws InvalidDataTypeException |
|
90 | - * @throws InvalidInterfaceException |
|
91 | - * @throws InvalidArgumentException |
|
92 | - * @throws ReflectionException |
|
93 | - * @since $VID:$ |
|
94 | - */ |
|
95 | - public function convert($datetime) |
|
96 | - { |
|
97 | - return $datetime instanceof EE_Datetime ? [ |
|
98 | - 'DTT_ID' => $datetime->ID(), |
|
99 | - 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
100 | - 'DTT_name' => $datetime->name(), |
|
101 | - 'DTT_description' => $datetime->description(), |
|
102 | - 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
103 | - 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
104 | - 'DTT_sold' => $datetime->sold(), |
|
105 | - 'DTT_reserved' => $datetime->reserved(), |
|
106 | - 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
107 | - 'DTT_is_primary' => $datetime->get_active_status(), |
|
108 | - 'DTT_order' => $datetime->order(), |
|
109 | - 'DTT_parent' => $datetime->parent(), |
|
110 | - 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
111 | - ] : []; |
|
112 | - } |
|
85 | + /** |
|
86 | + * @param EE_Datetime $datetime |
|
87 | + * @return array |
|
88 | + * @throws EE_Error |
|
89 | + * @throws InvalidDataTypeException |
|
90 | + * @throws InvalidInterfaceException |
|
91 | + * @throws InvalidArgumentException |
|
92 | + * @throws ReflectionException |
|
93 | + * @since $VID:$ |
|
94 | + */ |
|
95 | + public function convert($datetime) |
|
96 | + { |
|
97 | + return $datetime instanceof EE_Datetime ? [ |
|
98 | + 'DTT_ID' => $datetime->ID(), |
|
99 | + 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
100 | + 'DTT_name' => $datetime->name(), |
|
101 | + 'DTT_description' => $datetime->description(), |
|
102 | + 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
103 | + 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
104 | + 'DTT_sold' => $datetime->sold(), |
|
105 | + 'DTT_reserved' => $datetime->reserved(), |
|
106 | + 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
107 | + 'DTT_is_primary' => $datetime->get_active_status(), |
|
108 | + 'DTT_order' => $datetime->order(), |
|
109 | + 'DTT_parent' => $datetime->parent(), |
|
110 | + 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
111 | + ] : []; |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | - /** |
|
116 | - * @param EE_Datetime[] $datetimes |
|
117 | - * @return array |
|
118 | - * @throws EE_Error |
|
119 | - * @throws InvalidArgumentException |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidInterfaceException |
|
122 | - * @throws ReflectionException |
|
123 | - * @since $VID:$ |
|
124 | - */ |
|
125 | - public function encodeArrayOf(array $datetimes) |
|
126 | - { |
|
127 | - $jsonDates = []; |
|
128 | - foreach ($datetimes as $datetime) { |
|
129 | - if ($datetime instanceof EE_Datetime) { |
|
130 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
131 | - } |
|
132 | - } |
|
133 | - return $jsonDates; |
|
134 | - } |
|
115 | + /** |
|
116 | + * @param EE_Datetime[] $datetimes |
|
117 | + * @return array |
|
118 | + * @throws EE_Error |
|
119 | + * @throws InvalidArgumentException |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidInterfaceException |
|
122 | + * @throws ReflectionException |
|
123 | + * @since $VID:$ |
|
124 | + */ |
|
125 | + public function encodeArrayOf(array $datetimes) |
|
126 | + { |
|
127 | + $jsonDates = []; |
|
128 | + foreach ($datetimes as $datetime) { |
|
129 | + if ($datetime instanceof EE_Datetime) { |
|
130 | + $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
131 | + } |
|
132 | + } |
|
133 | + return $jsonDates; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | - /** |
|
138 | - * @param array $datetime_array |
|
139 | - * @return false|string |
|
140 | - * @since $VID:$ |
|
141 | - */ |
|
142 | - public function encode(array $datetime_array) |
|
143 | - { |
|
144 | - return wp_json_encode($datetime_array); |
|
145 | - } |
|
137 | + /** |
|
138 | + * @param array $datetime_array |
|
139 | + * @return false|string |
|
140 | + * @since $VID:$ |
|
141 | + */ |
|
142 | + public function encode(array $datetime_array) |
|
143 | + { |
|
144 | + return wp_json_encode($datetime_array); |
|
145 | + } |
|
146 | 146 | } |
@@ -19,66 +19,66 @@ |
||
19 | 19 | class EventVenuesConnection implements ConnectionInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EEM_Venue $model |
|
24 | - */ |
|
25 | - protected $model; |
|
22 | + /** |
|
23 | + * @var EEM_Venue $model |
|
24 | + */ |
|
25 | + protected $model; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * DatetimeConnection constructor. |
|
30 | - * |
|
31 | - * @param EEM_Venue $model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Venue $model) |
|
34 | - { |
|
35 | - $this->model = $model; |
|
36 | - } |
|
28 | + /** |
|
29 | + * DatetimeConnection constructor. |
|
30 | + * |
|
31 | + * @param EEM_Venue $model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Venue $model) |
|
34 | + { |
|
35 | + $this->model = $model; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function config() |
|
44 | - { |
|
45 | - return [ |
|
46 | - 'fromType' => 'Event', |
|
47 | - 'toType' => 'Venue', |
|
48 | - 'fromFieldName' => 'venues', |
|
49 | - 'connectionTypeName' => 'EventVenuesConnection', |
|
50 | - 'resolve' => [$this, 'resolveConnection'], |
|
51 | - 'resolveNode' => [$this, 'resolveNode'], |
|
52 | - ]; |
|
53 | - } |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function config() |
|
44 | + { |
|
45 | + return [ |
|
46 | + 'fromType' => 'Event', |
|
47 | + 'toType' => 'Venue', |
|
48 | + 'fromFieldName' => 'venues', |
|
49 | + 'connectionTypeName' => 'EventVenuesConnection', |
|
50 | + 'resolve' => [$this, 'resolveConnection'], |
|
51 | + 'resolveNode' => [$this, 'resolveNode'], |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param $entity |
|
58 | - * @param $args |
|
59 | - * @param $context |
|
60 | - * @param $info |
|
61 | - * @return array |
|
62 | - * @throws Exception |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function resolveConnection($entity, $args, $context, $info) |
|
66 | - { |
|
67 | - $resolver = new VenueConnectionResolver($entity, $args, $context, $info); |
|
68 | - return $resolver->get_connection(); |
|
69 | - } |
|
56 | + /** |
|
57 | + * @param $entity |
|
58 | + * @param $args |
|
59 | + * @param $context |
|
60 | + * @param $info |
|
61 | + * @return array |
|
62 | + * @throws Exception |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function resolveConnection($entity, $args, $context, $info) |
|
66 | + { |
|
67 | + $resolver = new VenueConnectionResolver($entity, $args, $context, $info); |
|
68 | + return $resolver->get_connection(); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param $id |
|
74 | - * @param $args |
|
75 | - * @param $context |
|
76 | - * @param $info |
|
77 | - * @return EE_Base_Class |
|
78 | - * @since $VID:$ |
|
79 | - */ |
|
80 | - public function resolveNode($id, $args, $context, $info) |
|
81 | - { |
|
82 | - return $this->model->get_one_by_ID($id); |
|
83 | - } |
|
72 | + /** |
|
73 | + * @param $id |
|
74 | + * @param $args |
|
75 | + * @param $context |
|
76 | + * @param $info |
|
77 | + * @return EE_Base_Class |
|
78 | + * @since $VID:$ |
|
79 | + */ |
|
80 | + public function resolveNode($id, $args, $context, $info) |
|
81 | + { |
|
82 | + return $this->model->get_one_by_ID($id); |
|
83 | + } |
|
84 | 84 | } |
@@ -19,66 +19,66 @@ |
||
19 | 19 | class TicketDatetimesConnection implements ConnectionInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EEM_Datetime $model |
|
24 | - */ |
|
25 | - protected $model; |
|
22 | + /** |
|
23 | + * @var EEM_Datetime $model |
|
24 | + */ |
|
25 | + protected $model; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * DatetimeConnection constructor. |
|
30 | - * |
|
31 | - * @param EEM_Datetime $model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Datetime $model) |
|
34 | - { |
|
35 | - $this->model = $model; |
|
36 | - } |
|
28 | + /** |
|
29 | + * DatetimeConnection constructor. |
|
30 | + * |
|
31 | + * @param EEM_Datetime $model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Datetime $model) |
|
34 | + { |
|
35 | + $this->model = $model; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function config() |
|
44 | - { |
|
45 | - return [ |
|
46 | - 'fromType' => 'Ticket', |
|
47 | - 'toType' => 'Datetime', |
|
48 | - 'fromFieldName' => 'datetimes', |
|
49 | - 'connectionTypeName' => 'TicketDatetimesConnection', |
|
50 | - 'resolve' => [$this, 'resolveConnection'], |
|
51 | - 'resolveNode' => [$this, 'resolveNode'], |
|
52 | - ]; |
|
53 | - } |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function config() |
|
44 | + { |
|
45 | + return [ |
|
46 | + 'fromType' => 'Ticket', |
|
47 | + 'toType' => 'Datetime', |
|
48 | + 'fromFieldName' => 'datetimes', |
|
49 | + 'connectionTypeName' => 'TicketDatetimesConnection', |
|
50 | + 'resolve' => [$this, 'resolveConnection'], |
|
51 | + 'resolveNode' => [$this, 'resolveNode'], |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param $entity |
|
58 | - * @param $args |
|
59 | - * @param $context |
|
60 | - * @param $info |
|
61 | - * @return array |
|
62 | - * @throws Exception |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function resolveConnection($entity, $args, $context, $info) |
|
66 | - { |
|
67 | - $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
68 | - return $resolver->get_connection(); |
|
69 | - } |
|
56 | + /** |
|
57 | + * @param $entity |
|
58 | + * @param $args |
|
59 | + * @param $context |
|
60 | + * @param $info |
|
61 | + * @return array |
|
62 | + * @throws Exception |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function resolveConnection($entity, $args, $context, $info) |
|
66 | + { |
|
67 | + $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
68 | + return $resolver->get_connection(); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param $id |
|
74 | - * @param $args |
|
75 | - * @param $context |
|
76 | - * @param $info |
|
77 | - * @return EE_Base_Class |
|
78 | - * @since $VID:$ |
|
79 | - */ |
|
80 | - public function resolveNode($id, $args, $context, $info) |
|
81 | - { |
|
82 | - return $this->model->get_one_by_ID($id); |
|
83 | - } |
|
72 | + /** |
|
73 | + * @param $id |
|
74 | + * @param $args |
|
75 | + * @param $context |
|
76 | + * @param $info |
|
77 | + * @return EE_Base_Class |
|
78 | + * @since $VID:$ |
|
79 | + */ |
|
80 | + public function resolveNode($id, $args, $context, $info) |
|
81 | + { |
|
82 | + return $this->model->get_one_by_ID($id); |
|
83 | + } |
|
84 | 84 | } |
@@ -19,66 +19,66 @@ |
||
19 | 19 | class DatetimeTicketsConnection implements ConnectionInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var EEM_Ticket $model |
|
24 | - */ |
|
25 | - protected $model; |
|
22 | + /** |
|
23 | + * @var EEM_Ticket $model |
|
24 | + */ |
|
25 | + protected $model; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * DatetimeConnection constructor. |
|
30 | - * |
|
31 | - * @param EEM_Ticket $model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Ticket $model) |
|
34 | - { |
|
35 | - $this->model = $model; |
|
36 | - } |
|
28 | + /** |
|
29 | + * DatetimeConnection constructor. |
|
30 | + * |
|
31 | + * @param EEM_Ticket $model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Ticket $model) |
|
34 | + { |
|
35 | + $this->model = $model; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function config() |
|
44 | - { |
|
45 | - return [ |
|
46 | - 'fromType' => 'Datetime', |
|
47 | - 'toType' => 'Ticket', |
|
48 | - 'fromFieldName' => 'tickets', |
|
49 | - 'connectionTypeName' => 'DatetimeTicketsConnection', |
|
50 | - 'resolve' => [$this, 'resolveConnection'], |
|
51 | - 'resolveNode' => [$this, 'resolveNode'] |
|
52 | - ]; |
|
53 | - } |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function config() |
|
44 | + { |
|
45 | + return [ |
|
46 | + 'fromType' => 'Datetime', |
|
47 | + 'toType' => 'Ticket', |
|
48 | + 'fromFieldName' => 'tickets', |
|
49 | + 'connectionTypeName' => 'DatetimeTicketsConnection', |
|
50 | + 'resolve' => [$this, 'resolveConnection'], |
|
51 | + 'resolveNode' => [$this, 'resolveNode'] |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param $entity |
|
58 | - * @param $args |
|
59 | - * @param $context |
|
60 | - * @param $info |
|
61 | - * @return array |
|
62 | - * @throws Exception |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function resolveConnection($entity, $args, $context, $info) |
|
66 | - { |
|
67 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
68 | - return $resolver->get_connection(); |
|
69 | - } |
|
56 | + /** |
|
57 | + * @param $entity |
|
58 | + * @param $args |
|
59 | + * @param $context |
|
60 | + * @param $info |
|
61 | + * @return array |
|
62 | + * @throws Exception |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function resolveConnection($entity, $args, $context, $info) |
|
66 | + { |
|
67 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
68 | + return $resolver->get_connection(); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param $id |
|
74 | - * @param $args |
|
75 | - * @param $context |
|
76 | - * @param $info |
|
77 | - * @return EE_Base_Class |
|
78 | - * @since $VID:$ |
|
79 | - */ |
|
80 | - public function resolveNode($id, $args, $context, $info) |
|
81 | - { |
|
82 | - return $this->model->get_one_by_ID($id); |
|
83 | - } |
|
72 | + /** |
|
73 | + * @param $id |
|
74 | + * @param $args |
|
75 | + * @param $context |
|
76 | + * @param $info |
|
77 | + * @return EE_Base_Class |
|
78 | + * @since $VID:$ |
|
79 | + */ |
|
80 | + public function resolveNode($id, $args, $context, $info) |
|
81 | + { |
|
82 | + return $this->model->get_one_by_ID($id); |
|
83 | + } |
|
84 | 84 | } |