@@ -34,172 +34,172 @@ |
||
| 34 | 34 | class Event extends TypeBase |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Event constructor. |
|
| 39 | - * |
|
| 40 | - * @param EEM_Event $event_model |
|
| 41 | - */ |
|
| 42 | - public function __construct(EEM_Event $event_model) |
|
| 43 | - { |
|
| 44 | - $this->model = $event_model; |
|
| 45 | - $this->setName('Event'); |
|
| 46 | - $this->setIsCustomPostType(true); |
|
| 47 | - parent::__construct(); |
|
| 48 | - } |
|
| 37 | + /** |
|
| 38 | + * Event constructor. |
|
| 39 | + * |
|
| 40 | + * @param EEM_Event $event_model |
|
| 41 | + */ |
|
| 42 | + public function __construct(EEM_Event $event_model) |
|
| 43 | + { |
|
| 44 | + $this->model = $event_model; |
|
| 45 | + $this->setName('Event'); |
|
| 46 | + $this->setIsCustomPostType(true); |
|
| 47 | + parent::__construct(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return GraphQLField[] |
|
| 53 | - * @since $VID:$ |
|
| 54 | - */ |
|
| 55 | - public function getFields() |
|
| 56 | - { |
|
| 57 | - return [ |
|
| 58 | - new GraphQLField( |
|
| 59 | - 'name', |
|
| 60 | - 'String', |
|
| 61 | - 'name', |
|
| 62 | - __('Event Name', 'event_espresso') |
|
| 63 | - ), |
|
| 64 | - new GraphQLField( |
|
| 65 | - 'desc', |
|
| 66 | - 'String', |
|
| 67 | - 'description', |
|
| 68 | - __('Event Description', 'event_espresso') |
|
| 69 | - ), |
|
| 70 | - new GraphQLField( |
|
| 71 | - 'shortDesc', |
|
| 72 | - 'String', |
|
| 73 | - 'short_description', |
|
| 74 | - __('Event Short Description', 'event_espresso') |
|
| 75 | - ), |
|
| 76 | - new GraphQLField( |
|
| 77 | - 'created', |
|
| 78 | - 'String', |
|
| 79 | - 'created', |
|
| 80 | - __('Date/Time Event Created', 'event_espresso') |
|
| 81 | - ), |
|
| 82 | - new GraphQLOutputField( |
|
| 83 | - 'wpUser', |
|
| 84 | - 'User', |
|
| 85 | - null, |
|
| 86 | - __('Event Creator', 'event_espresso') |
|
| 87 | - ), |
|
| 88 | - new GraphQLInputField( |
|
| 89 | - 'wpUser', |
|
| 90 | - 'Int', |
|
| 91 | - null, |
|
| 92 | - __('Event Creator ID', 'event_espresso') |
|
| 93 | - ), |
|
| 94 | - new GraphQLField( |
|
| 95 | - 'order', |
|
| 96 | - 'Int', |
|
| 97 | - 'order', |
|
| 98 | - __('Event Menu Order', 'event_espresso') |
|
| 99 | - ), |
|
| 100 | - new GraphQLField( |
|
| 101 | - 'displayDesc', |
|
| 102 | - 'Boolean', |
|
| 103 | - 'display_description', |
|
| 104 | - __('Display Description Flag', 'event_espresso') |
|
| 105 | - ), |
|
| 106 | - new GraphQLField( |
|
| 107 | - 'displayTicketSelector', |
|
| 108 | - 'Boolean', |
|
| 109 | - 'display_ticket_selector', |
|
| 110 | - __('Display Ticket Selector Flag', 'event_espresso') |
|
| 111 | - ), |
|
| 112 | - new GraphQLField( |
|
| 113 | - 'visibleOn', |
|
| 114 | - 'String', |
|
| 115 | - 'visible_on', |
|
| 116 | - __('Event Visible Date', 'event_espresso') |
|
| 117 | - ), |
|
| 118 | - new GraphQLField( |
|
| 119 | - 'additionalLimit', |
|
| 120 | - 'String', |
|
| 121 | - 'additional_limit', |
|
| 122 | - __('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
| 123 | - ), |
|
| 124 | - new GraphQLField( |
|
| 125 | - 'phone', |
|
| 126 | - 'String', |
|
| 127 | - 'phone', |
|
| 128 | - __('Event Phone Number', 'event_espresso') |
|
| 129 | - ), |
|
| 130 | - new GraphQLField( |
|
| 131 | - 'memberOnly', |
|
| 132 | - 'Boolean', |
|
| 133 | - 'member_only', |
|
| 134 | - __('Member-Only Event Flag', 'event_espresso') |
|
| 135 | - ), |
|
| 136 | - new GraphQLField( |
|
| 137 | - 'allowOverflow', |
|
| 138 | - 'Boolean', |
|
| 139 | - 'allow_overflow', |
|
| 140 | - __('Allow Overflow on Event', 'event_espresso') |
|
| 141 | - ), |
|
| 142 | - new GraphQLField( |
|
| 143 | - 'timezoneString', |
|
| 144 | - 'String', |
|
| 145 | - 'timezone_string', |
|
| 146 | - __('Timezone (name) for Event times', 'event_espresso') |
|
| 147 | - ), |
|
| 148 | - new GraphQLField( |
|
| 149 | - 'externalUrl', |
|
| 150 | - 'String', |
|
| 151 | - 'external_url', |
|
| 152 | - __('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
| 153 | - ), |
|
| 154 | - new GraphQLField( |
|
| 155 | - 'donations', |
|
| 156 | - 'Boolean', |
|
| 157 | - 'donations', |
|
| 158 | - __('Accept Donations?', 'event_espresso') |
|
| 159 | - ), |
|
| 160 | - new GraphQLField( |
|
| 161 | - 'isSoldOut', |
|
| 162 | - 'Boolean', |
|
| 163 | - 'is_sold_out', |
|
| 164 | - __('Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
| 165 | - 'event_espresso') |
|
| 166 | - ), |
|
| 167 | - new GraphQLField( |
|
| 168 | - 'isPostponed', |
|
| 169 | - 'Boolean', |
|
| 170 | - 'is_postponed', |
|
| 171 | - __('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
| 172 | - ), |
|
| 173 | - new GraphQLField( |
|
| 174 | - 'isCancelled', |
|
| 175 | - 'Boolean', |
|
| 176 | - 'is_cancelled', |
|
| 177 | - __('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
| 178 | - ), |
|
| 179 | - new GraphQLField( |
|
| 180 | - 'isUpcoming', |
|
| 181 | - 'Boolean', |
|
| 182 | - 'is_upcoming', |
|
| 183 | - __('Whether the event is upcoming', 'event_espresso') |
|
| 184 | - ), |
|
| 185 | - new GraphQLField( |
|
| 186 | - 'isActive', |
|
| 187 | - 'Boolean', |
|
| 188 | - 'is_active', |
|
| 189 | - __('Flag indicating event is active', 'event_espresso') |
|
| 190 | - ), |
|
| 191 | - new GraphQLField( |
|
| 192 | - 'isInactive', |
|
| 193 | - 'Boolean', |
|
| 194 | - 'is_inactive', |
|
| 195 | - __('Flag indicating event is inactive', 'event_espresso') |
|
| 196 | - ), |
|
| 197 | - new GraphQLField( |
|
| 198 | - 'isExpired', |
|
| 199 | - 'Boolean', |
|
| 200 | - 'is_expired', |
|
| 201 | - __('Flag indicating event is expired or not', 'event_espresso') |
|
| 202 | - ), |
|
| 203 | - ]; |
|
| 204 | - } |
|
| 51 | + /** |
|
| 52 | + * @return GraphQLField[] |
|
| 53 | + * @since $VID:$ |
|
| 54 | + */ |
|
| 55 | + public function getFields() |
|
| 56 | + { |
|
| 57 | + return [ |
|
| 58 | + new GraphQLField( |
|
| 59 | + 'name', |
|
| 60 | + 'String', |
|
| 61 | + 'name', |
|
| 62 | + __('Event Name', 'event_espresso') |
|
| 63 | + ), |
|
| 64 | + new GraphQLField( |
|
| 65 | + 'desc', |
|
| 66 | + 'String', |
|
| 67 | + 'description', |
|
| 68 | + __('Event Description', 'event_espresso') |
|
| 69 | + ), |
|
| 70 | + new GraphQLField( |
|
| 71 | + 'shortDesc', |
|
| 72 | + 'String', |
|
| 73 | + 'short_description', |
|
| 74 | + __('Event Short Description', 'event_espresso') |
|
| 75 | + ), |
|
| 76 | + new GraphQLField( |
|
| 77 | + 'created', |
|
| 78 | + 'String', |
|
| 79 | + 'created', |
|
| 80 | + __('Date/Time Event Created', 'event_espresso') |
|
| 81 | + ), |
|
| 82 | + new GraphQLOutputField( |
|
| 83 | + 'wpUser', |
|
| 84 | + 'User', |
|
| 85 | + null, |
|
| 86 | + __('Event Creator', 'event_espresso') |
|
| 87 | + ), |
|
| 88 | + new GraphQLInputField( |
|
| 89 | + 'wpUser', |
|
| 90 | + 'Int', |
|
| 91 | + null, |
|
| 92 | + __('Event Creator ID', 'event_espresso') |
|
| 93 | + ), |
|
| 94 | + new GraphQLField( |
|
| 95 | + 'order', |
|
| 96 | + 'Int', |
|
| 97 | + 'order', |
|
| 98 | + __('Event Menu Order', 'event_espresso') |
|
| 99 | + ), |
|
| 100 | + new GraphQLField( |
|
| 101 | + 'displayDesc', |
|
| 102 | + 'Boolean', |
|
| 103 | + 'display_description', |
|
| 104 | + __('Display Description Flag', 'event_espresso') |
|
| 105 | + ), |
|
| 106 | + new GraphQLField( |
|
| 107 | + 'displayTicketSelector', |
|
| 108 | + 'Boolean', |
|
| 109 | + 'display_ticket_selector', |
|
| 110 | + __('Display Ticket Selector Flag', 'event_espresso') |
|
| 111 | + ), |
|
| 112 | + new GraphQLField( |
|
| 113 | + 'visibleOn', |
|
| 114 | + 'String', |
|
| 115 | + 'visible_on', |
|
| 116 | + __('Event Visible Date', 'event_espresso') |
|
| 117 | + ), |
|
| 118 | + new GraphQLField( |
|
| 119 | + 'additionalLimit', |
|
| 120 | + 'String', |
|
| 121 | + 'additional_limit', |
|
| 122 | + __('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
| 123 | + ), |
|
| 124 | + new GraphQLField( |
|
| 125 | + 'phone', |
|
| 126 | + 'String', |
|
| 127 | + 'phone', |
|
| 128 | + __('Event Phone Number', 'event_espresso') |
|
| 129 | + ), |
|
| 130 | + new GraphQLField( |
|
| 131 | + 'memberOnly', |
|
| 132 | + 'Boolean', |
|
| 133 | + 'member_only', |
|
| 134 | + __('Member-Only Event Flag', 'event_espresso') |
|
| 135 | + ), |
|
| 136 | + new GraphQLField( |
|
| 137 | + 'allowOverflow', |
|
| 138 | + 'Boolean', |
|
| 139 | + 'allow_overflow', |
|
| 140 | + __('Allow Overflow on Event', 'event_espresso') |
|
| 141 | + ), |
|
| 142 | + new GraphQLField( |
|
| 143 | + 'timezoneString', |
|
| 144 | + 'String', |
|
| 145 | + 'timezone_string', |
|
| 146 | + __('Timezone (name) for Event times', 'event_espresso') |
|
| 147 | + ), |
|
| 148 | + new GraphQLField( |
|
| 149 | + 'externalUrl', |
|
| 150 | + 'String', |
|
| 151 | + 'external_url', |
|
| 152 | + __('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
| 153 | + ), |
|
| 154 | + new GraphQLField( |
|
| 155 | + 'donations', |
|
| 156 | + 'Boolean', |
|
| 157 | + 'donations', |
|
| 158 | + __('Accept Donations?', 'event_espresso') |
|
| 159 | + ), |
|
| 160 | + new GraphQLField( |
|
| 161 | + 'isSoldOut', |
|
| 162 | + 'Boolean', |
|
| 163 | + 'is_sold_out', |
|
| 164 | + __('Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
| 165 | + 'event_espresso') |
|
| 166 | + ), |
|
| 167 | + new GraphQLField( |
|
| 168 | + 'isPostponed', |
|
| 169 | + 'Boolean', |
|
| 170 | + 'is_postponed', |
|
| 171 | + __('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
| 172 | + ), |
|
| 173 | + new GraphQLField( |
|
| 174 | + 'isCancelled', |
|
| 175 | + 'Boolean', |
|
| 176 | + 'is_cancelled', |
|
| 177 | + __('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
| 178 | + ), |
|
| 179 | + new GraphQLField( |
|
| 180 | + 'isUpcoming', |
|
| 181 | + 'Boolean', |
|
| 182 | + 'is_upcoming', |
|
| 183 | + __('Whether the event is upcoming', 'event_espresso') |
|
| 184 | + ), |
|
| 185 | + new GraphQLField( |
|
| 186 | + 'isActive', |
|
| 187 | + 'Boolean', |
|
| 188 | + 'is_active', |
|
| 189 | + __('Flag indicating event is active', 'event_espresso') |
|
| 190 | + ), |
|
| 191 | + new GraphQLField( |
|
| 192 | + 'isInactive', |
|
| 193 | + 'Boolean', |
|
| 194 | + 'is_inactive', |
|
| 195 | + __('Flag indicating event is inactive', 'event_espresso') |
|
| 196 | + ), |
|
| 197 | + new GraphQLField( |
|
| 198 | + 'isExpired', |
|
| 199 | + 'Boolean', |
|
| 200 | + 'is_expired', |
|
| 201 | + __('Flag indicating event is expired or not', 'event_espresso') |
|
| 202 | + ), |
|
| 203 | + ]; |
|
| 204 | + } |
|
| 205 | 205 | } |
| 206 | 206 | \ No newline at end of file |
@@ -34,166 +34,166 @@ |
||
| 34 | 34 | class Venue extends TypeBase |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Venue constructor. |
|
| 39 | - * |
|
| 40 | - * @param EEM_Venue $venue_model |
|
| 41 | - */ |
|
| 42 | - public function __construct(EEM_Venue $venue_model) |
|
| 43 | - { |
|
| 44 | - $this->model = $venue_model; |
|
| 45 | - $this->setName('Venue'); |
|
| 46 | - $this->setIsCustomPostType(true); |
|
| 47 | - parent::__construct(); |
|
| 48 | - } |
|
| 37 | + /** |
|
| 38 | + * Venue constructor. |
|
| 39 | + * |
|
| 40 | + * @param EEM_Venue $venue_model |
|
| 41 | + */ |
|
| 42 | + public function __construct(EEM_Venue $venue_model) |
|
| 43 | + { |
|
| 44 | + $this->model = $venue_model; |
|
| 45 | + $this->setName('Venue'); |
|
| 46 | + $this->setIsCustomPostType(true); |
|
| 47 | + parent::__construct(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return GraphQLField[] |
|
| 53 | - * @since $VID:$ |
|
| 54 | - */ |
|
| 55 | - public function getFields() |
|
| 56 | - { |
|
| 57 | - return [ |
|
| 58 | - new GraphQLField( |
|
| 59 | - 'name', |
|
| 60 | - 'String', |
|
| 61 | - 'name', |
|
| 62 | - __('Venue Name', 'event_espresso') |
|
| 63 | - ), |
|
| 64 | - new GraphQLField( |
|
| 65 | - 'desc', |
|
| 66 | - 'String', |
|
| 67 | - 'description', |
|
| 68 | - __('Venue Description', 'event_espresso') |
|
| 69 | - ), |
|
| 70 | - new GraphQLField( |
|
| 71 | - 'shortDesc', |
|
| 72 | - 'String', |
|
| 73 | - 'excerpt', |
|
| 74 | - __('Short Description of Venue', 'event_espresso') |
|
| 75 | - ), |
|
| 76 | - new GraphQLField( |
|
| 77 | - 'identifier', |
|
| 78 | - 'String', |
|
| 79 | - 'identifier', |
|
| 80 | - __('Venue Identifier', 'event_espresso') |
|
| 81 | - ), |
|
| 82 | - new GraphQLField( |
|
| 83 | - 'created', |
|
| 84 | - 'String', |
|
| 85 | - 'created', |
|
| 86 | - __('Date Venue Created', 'event_espresso') |
|
| 87 | - ), |
|
| 88 | - new GraphQLField( |
|
| 89 | - 'order', |
|
| 90 | - 'Int', |
|
| 91 | - 'order', |
|
| 92 | - __('Venue order', 'event_espresso') |
|
| 93 | - ), |
|
| 94 | - new GraphQLOutputField( |
|
| 95 | - 'wpUser', |
|
| 96 | - 'User', |
|
| 97 | - null, |
|
| 98 | - __('Venue Creator', 'event_espresso') |
|
| 99 | - ), |
|
| 100 | - new GraphQLInputField( |
|
| 101 | - 'wpUser', |
|
| 102 | - 'Int', |
|
| 103 | - null, |
|
| 104 | - __('Venue Creator ID', 'event_espresso') |
|
| 105 | - ), |
|
| 106 | - new GraphQLField( |
|
| 107 | - 'address', |
|
| 108 | - 'String', |
|
| 109 | - 'address', |
|
| 110 | - __('Venue Address line 1', 'event_espresso') |
|
| 111 | - ), |
|
| 112 | - new GraphQLField( |
|
| 113 | - 'address2', |
|
| 114 | - 'String', |
|
| 115 | - 'address2', |
|
| 116 | - __('Venue Address line 2', 'event_espresso') |
|
| 117 | - ), |
|
| 118 | - new GraphQLField( |
|
| 119 | - 'city', |
|
| 120 | - 'String', |
|
| 121 | - 'city', |
|
| 122 | - __('Venue City', 'event_espresso') |
|
| 123 | - ), |
|
| 124 | - new GraphQLOutputField( |
|
| 125 | - 'state', |
|
| 126 | - 'State', |
|
| 127 | - null, |
|
| 128 | - __('Venue state', 'event_espresso') |
|
| 129 | - ), |
|
| 130 | - new GraphQLInputField( |
|
| 131 | - 'state', |
|
| 132 | - 'Int', |
|
| 133 | - null, |
|
| 134 | - __('State ID', 'event_espresso') |
|
| 135 | - ), |
|
| 136 | - new GraphQLOutputField( |
|
| 137 | - 'country', |
|
| 138 | - 'Country', |
|
| 139 | - null, |
|
| 140 | - __('Venue country', 'event_espresso') |
|
| 141 | - ), |
|
| 142 | - new GraphQLInputField( |
|
| 143 | - 'country', |
|
| 144 | - 'String', |
|
| 145 | - null, |
|
| 146 | - __('Country ISO Code', 'event_espresso') |
|
| 147 | - ), |
|
| 148 | - new GraphQLField( |
|
| 149 | - 'zip', |
|
| 150 | - 'String', |
|
| 151 | - 'zip', |
|
| 152 | - __('Venue Zip/Postal Code', 'event_espresso') |
|
| 153 | - ), |
|
| 154 | - new GraphQLField( |
|
| 155 | - 'capacity', |
|
| 156 | - 'Int', |
|
| 157 | - 'capacity', |
|
| 158 | - __('Venue Capacity', 'event_espresso'), |
|
| 159 | - [$this, 'parseInfiniteValue'] |
|
| 160 | - ), |
|
| 161 | - new GraphQLField( |
|
| 162 | - 'phone', |
|
| 163 | - 'String', |
|
| 164 | - 'phone', |
|
| 165 | - __('Venue Phone', 'event_espresso') |
|
| 166 | - ), |
|
| 167 | - new GraphQLField( |
|
| 168 | - 'virtualPhone', |
|
| 169 | - 'String', |
|
| 170 | - 'virtual_phone', |
|
| 171 | - __('Call in Number', 'event_espresso') |
|
| 172 | - ), |
|
| 173 | - new GraphQLField( |
|
| 174 | - 'url', |
|
| 175 | - 'String', |
|
| 176 | - 'venue_url', |
|
| 177 | - __('Venue Website', 'event_espresso') |
|
| 178 | - ), |
|
| 179 | - new GraphQLField( |
|
| 180 | - 'virtualUrl', |
|
| 181 | - 'String', |
|
| 182 | - 'virtual_url', |
|
| 183 | - __('Virtual URL', 'event_espresso') |
|
| 184 | - ), |
|
| 185 | - new GraphQLField( |
|
| 186 | - 'googleMapLink', |
|
| 187 | - 'String', |
|
| 188 | - 'google_map_link', |
|
| 189 | - __('Google Map Link', 'event_espresso') |
|
| 190 | - ), |
|
| 191 | - new GraphQLField( |
|
| 192 | - 'enableForGmap', |
|
| 193 | - 'String', |
|
| 194 | - 'enable_for_gmap', |
|
| 195 | - __('Show Google Map?', 'event_espresso') |
|
| 196 | - ), |
|
| 197 | - ]; |
|
| 198 | - } |
|
| 51 | + /** |
|
| 52 | + * @return GraphQLField[] |
|
| 53 | + * @since $VID:$ |
|
| 54 | + */ |
|
| 55 | + public function getFields() |
|
| 56 | + { |
|
| 57 | + return [ |
|
| 58 | + new GraphQLField( |
|
| 59 | + 'name', |
|
| 60 | + 'String', |
|
| 61 | + 'name', |
|
| 62 | + __('Venue Name', 'event_espresso') |
|
| 63 | + ), |
|
| 64 | + new GraphQLField( |
|
| 65 | + 'desc', |
|
| 66 | + 'String', |
|
| 67 | + 'description', |
|
| 68 | + __('Venue Description', 'event_espresso') |
|
| 69 | + ), |
|
| 70 | + new GraphQLField( |
|
| 71 | + 'shortDesc', |
|
| 72 | + 'String', |
|
| 73 | + 'excerpt', |
|
| 74 | + __('Short Description of Venue', 'event_espresso') |
|
| 75 | + ), |
|
| 76 | + new GraphQLField( |
|
| 77 | + 'identifier', |
|
| 78 | + 'String', |
|
| 79 | + 'identifier', |
|
| 80 | + __('Venue Identifier', 'event_espresso') |
|
| 81 | + ), |
|
| 82 | + new GraphQLField( |
|
| 83 | + 'created', |
|
| 84 | + 'String', |
|
| 85 | + 'created', |
|
| 86 | + __('Date Venue Created', 'event_espresso') |
|
| 87 | + ), |
|
| 88 | + new GraphQLField( |
|
| 89 | + 'order', |
|
| 90 | + 'Int', |
|
| 91 | + 'order', |
|
| 92 | + __('Venue order', 'event_espresso') |
|
| 93 | + ), |
|
| 94 | + new GraphQLOutputField( |
|
| 95 | + 'wpUser', |
|
| 96 | + 'User', |
|
| 97 | + null, |
|
| 98 | + __('Venue Creator', 'event_espresso') |
|
| 99 | + ), |
|
| 100 | + new GraphQLInputField( |
|
| 101 | + 'wpUser', |
|
| 102 | + 'Int', |
|
| 103 | + null, |
|
| 104 | + __('Venue Creator ID', 'event_espresso') |
|
| 105 | + ), |
|
| 106 | + new GraphQLField( |
|
| 107 | + 'address', |
|
| 108 | + 'String', |
|
| 109 | + 'address', |
|
| 110 | + __('Venue Address line 1', 'event_espresso') |
|
| 111 | + ), |
|
| 112 | + new GraphQLField( |
|
| 113 | + 'address2', |
|
| 114 | + 'String', |
|
| 115 | + 'address2', |
|
| 116 | + __('Venue Address line 2', 'event_espresso') |
|
| 117 | + ), |
|
| 118 | + new GraphQLField( |
|
| 119 | + 'city', |
|
| 120 | + 'String', |
|
| 121 | + 'city', |
|
| 122 | + __('Venue City', 'event_espresso') |
|
| 123 | + ), |
|
| 124 | + new GraphQLOutputField( |
|
| 125 | + 'state', |
|
| 126 | + 'State', |
|
| 127 | + null, |
|
| 128 | + __('Venue state', 'event_espresso') |
|
| 129 | + ), |
|
| 130 | + new GraphQLInputField( |
|
| 131 | + 'state', |
|
| 132 | + 'Int', |
|
| 133 | + null, |
|
| 134 | + __('State ID', 'event_espresso') |
|
| 135 | + ), |
|
| 136 | + new GraphQLOutputField( |
|
| 137 | + 'country', |
|
| 138 | + 'Country', |
|
| 139 | + null, |
|
| 140 | + __('Venue country', 'event_espresso') |
|
| 141 | + ), |
|
| 142 | + new GraphQLInputField( |
|
| 143 | + 'country', |
|
| 144 | + 'String', |
|
| 145 | + null, |
|
| 146 | + __('Country ISO Code', 'event_espresso') |
|
| 147 | + ), |
|
| 148 | + new GraphQLField( |
|
| 149 | + 'zip', |
|
| 150 | + 'String', |
|
| 151 | + 'zip', |
|
| 152 | + __('Venue Zip/Postal Code', 'event_espresso') |
|
| 153 | + ), |
|
| 154 | + new GraphQLField( |
|
| 155 | + 'capacity', |
|
| 156 | + 'Int', |
|
| 157 | + 'capacity', |
|
| 158 | + __('Venue Capacity', 'event_espresso'), |
|
| 159 | + [$this, 'parseInfiniteValue'] |
|
| 160 | + ), |
|
| 161 | + new GraphQLField( |
|
| 162 | + 'phone', |
|
| 163 | + 'String', |
|
| 164 | + 'phone', |
|
| 165 | + __('Venue Phone', 'event_espresso') |
|
| 166 | + ), |
|
| 167 | + new GraphQLField( |
|
| 168 | + 'virtualPhone', |
|
| 169 | + 'String', |
|
| 170 | + 'virtual_phone', |
|
| 171 | + __('Call in Number', 'event_espresso') |
|
| 172 | + ), |
|
| 173 | + new GraphQLField( |
|
| 174 | + 'url', |
|
| 175 | + 'String', |
|
| 176 | + 'venue_url', |
|
| 177 | + __('Venue Website', 'event_espresso') |
|
| 178 | + ), |
|
| 179 | + new GraphQLField( |
|
| 180 | + 'virtualUrl', |
|
| 181 | + 'String', |
|
| 182 | + 'virtual_url', |
|
| 183 | + __('Virtual URL', 'event_espresso') |
|
| 184 | + ), |
|
| 185 | + new GraphQLField( |
|
| 186 | + 'googleMapLink', |
|
| 187 | + 'String', |
|
| 188 | + 'google_map_link', |
|
| 189 | + __('Google Map Link', 'event_espresso') |
|
| 190 | + ), |
|
| 191 | + new GraphQLField( |
|
| 192 | + 'enableForGmap', |
|
| 193 | + 'String', |
|
| 194 | + 'enable_for_gmap', |
|
| 195 | + __('Show Google Map?', 'event_espresso') |
|
| 196 | + ), |
|
| 197 | + ]; |
|
| 198 | + } |
|
| 199 | 199 | } |
| 200 | 200 | \ No newline at end of file |
@@ -16,34 +16,34 @@ |
||
| 16 | 16 | class GraphQLOutputField extends GraphQLField |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 19 | + /** |
|
| 20 | 20 | * @param string $name |
| 21 | 21 | * @param string|string[] $type |
| 22 | - * @param string|null $key |
|
| 23 | - * @param string $description |
|
| 24 | - * @param callable|null $formatter |
|
| 25 | - * @param callable|null $resolver |
|
| 26 | - * @param array $caps |
|
| 27 | - */ |
|
| 28 | - public function __construct( |
|
| 22 | + * @param string|null $key |
|
| 23 | + * @param string $description |
|
| 24 | + * @param callable|null $formatter |
|
| 25 | + * @param callable|null $resolver |
|
| 26 | + * @param array $caps |
|
| 27 | + */ |
|
| 28 | + public function __construct( |
|
| 29 | 29 | $name, |
| 30 | - $type, |
|
| 31 | - $key = null, |
|
| 32 | - $description = '', |
|
| 33 | - callable $formatter = null, |
|
| 34 | - callable $resolver = null, |
|
| 35 | - array $caps = [] |
|
| 36 | - ) { |
|
| 37 | - parent::__construct( |
|
| 38 | - $name, |
|
| 39 | - $type, |
|
| 40 | - $key, |
|
| 41 | - $description, |
|
| 42 | - $formatter, |
|
| 43 | - $resolver, |
|
| 44 | - $caps |
|
| 45 | - ); |
|
| 30 | + $type, |
|
| 31 | + $key = null, |
|
| 32 | + $description = '', |
|
| 33 | + callable $formatter = null, |
|
| 34 | + callable $resolver = null, |
|
| 35 | + array $caps = [] |
|
| 36 | + ) { |
|
| 37 | + parent::__construct( |
|
| 38 | + $name, |
|
| 39 | + $type, |
|
| 40 | + $key, |
|
| 41 | + $description, |
|
| 42 | + $formatter, |
|
| 43 | + $resolver, |
|
| 44 | + $caps |
|
| 45 | + ); |
|
| 46 | 46 | |
| 47 | - $this->setUseForInput(false); |
|
| 48 | - } |
|
| 47 | + $this->setUseForInput(false); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -16,30 +16,30 @@ |
||
| 16 | 16 | class GraphQLInputField extends GraphQLField |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 19 | + /** |
|
| 20 | 20 | * @param string $name |
| 21 | 21 | * @param string|string[] $type |
| 22 | - * @param string|null $key |
|
| 23 | - * @param string $description |
|
| 24 | - * @param array $caps |
|
| 25 | - */ |
|
| 26 | - public function __construct( |
|
| 22 | + * @param string|null $key |
|
| 23 | + * @param string $description |
|
| 24 | + * @param array $caps |
|
| 25 | + */ |
|
| 26 | + public function __construct( |
|
| 27 | 27 | $name, |
| 28 | - $type, |
|
| 29 | - $key = null, |
|
| 30 | - $description = '', |
|
| 31 | - array $caps = [] |
|
| 32 | - ) { |
|
| 33 | - parent::__construct( |
|
| 34 | - $name, |
|
| 35 | - $type, |
|
| 36 | - $key, |
|
| 37 | - $description, |
|
| 38 | - null, |
|
| 39 | - null, |
|
| 40 | - $caps |
|
| 41 | - ); |
|
| 28 | + $type, |
|
| 29 | + $key = null, |
|
| 30 | + $description = '', |
|
| 31 | + array $caps = [] |
|
| 32 | + ) { |
|
| 33 | + parent::__construct( |
|
| 34 | + $name, |
|
| 35 | + $type, |
|
| 36 | + $key, |
|
| 37 | + $description, |
|
| 38 | + null, |
|
| 39 | + null, |
|
| 40 | + $caps |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - $this->setUseForOutput(false); |
|
| 44 | - } |
|
| 43 | + $this->setUseForOutput(false); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -15,252 +15,252 @@ |
||
| 15 | 15 | class GraphQLField |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var string $name |
|
| 20 | - */ |
|
| 21 | - protected $name; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @var string|string[] $type |
|
| 25 | - */ |
|
| 26 | - protected $type; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var string|null $key |
|
| 30 | - */ |
|
| 31 | - protected $key; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var string $description |
|
| 35 | - */ |
|
| 36 | - protected $description; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var callable $formatter |
|
| 40 | - */ |
|
| 41 | - protected $formatter; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var callable $resolve |
|
| 45 | - */ |
|
| 46 | - protected $resolver; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var array $caps |
|
| 50 | - */ |
|
| 51 | - protected $caps; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var bool $use_for_input |
|
| 55 | - */ |
|
| 56 | - protected $use_for_input; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var bool $use_for_output |
|
| 60 | - */ |
|
| 61 | - protected $use_for_output; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 18 | + /** |
|
| 19 | + * @var string $name |
|
| 20 | + */ |
|
| 21 | + protected $name; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @var string|string[] $type |
|
| 25 | + */ |
|
| 26 | + protected $type; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var string|null $key |
|
| 30 | + */ |
|
| 31 | + protected $key; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var string $description |
|
| 35 | + */ |
|
| 36 | + protected $description; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var callable $formatter |
|
| 40 | + */ |
|
| 41 | + protected $formatter; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var callable $resolve |
|
| 45 | + */ |
|
| 46 | + protected $resolver; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var array $caps |
|
| 50 | + */ |
|
| 51 | + protected $caps; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var bool $use_for_input |
|
| 55 | + */ |
|
| 56 | + protected $use_for_input; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var bool $use_for_output |
|
| 60 | + */ |
|
| 61 | + protected $use_for_output; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | 65 | * @param string $name |
| 66 | 66 | * @param string|string[] $type |
| 67 | - * @param string|null $key |
|
| 68 | - * @param string $description |
|
| 69 | - * @param callable|null $formatter |
|
| 70 | - * @param callable|null $resolver |
|
| 71 | - * @param array $caps |
|
| 72 | - */ |
|
| 73 | - public function __construct( |
|
| 67 | + * @param string|null $key |
|
| 68 | + * @param string $description |
|
| 69 | + * @param callable|null $formatter |
|
| 70 | + * @param callable|null $resolver |
|
| 71 | + * @param array $caps |
|
| 72 | + */ |
|
| 73 | + public function __construct( |
|
| 74 | 74 | $name, |
| 75 | - $type, |
|
| 76 | - $key = null, |
|
| 77 | - $description = '', |
|
| 78 | - callable $formatter = null, |
|
| 79 | - callable $resolver = null, |
|
| 80 | - array $caps = [] |
|
| 81 | - ) { |
|
| 82 | - $this->name = $name; |
|
| 83 | - $this->type = $type; |
|
| 84 | - $this->key = $key; |
|
| 85 | - $this->description = $description; |
|
| 86 | - $this->formatter = $formatter; |
|
| 87 | - $this->resolver = $resolver; |
|
| 88 | - $this->caps = $caps; |
|
| 89 | - |
|
| 90 | - $this->use_for_input = true; |
|
| 91 | - $this->use_for_output = true; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @return array |
|
| 97 | - */ |
|
| 98 | - public function caps() |
|
| 99 | - { |
|
| 100 | - return $this->caps; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function description() |
|
| 108 | - { |
|
| 109 | - return $this->description; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 116 | - public function key() |
|
| 117 | - { |
|
| 118 | - return $this->key; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - public function name() |
|
| 126 | - { |
|
| 127 | - return $this->name; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return string|string[] |
|
| 133 | - */ |
|
| 134 | - public function type() |
|
| 135 | - { |
|
| 136 | - return $this->type; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Convert the field to array to be |
|
| 142 | - * able to pass as config to WP GraphQL |
|
| 143 | - * |
|
| 144 | - * @return array |
|
| 145 | - */ |
|
| 146 | - public function toArray() |
|
| 147 | - { |
|
| 148 | - return get_object_vars($this); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Sets the value for use_for_input. |
|
| 154 | - * |
|
| 75 | + $type, |
|
| 76 | + $key = null, |
|
| 77 | + $description = '', |
|
| 78 | + callable $formatter = null, |
|
| 79 | + callable $resolver = null, |
|
| 80 | + array $caps = [] |
|
| 81 | + ) { |
|
| 82 | + $this->name = $name; |
|
| 83 | + $this->type = $type; |
|
| 84 | + $this->key = $key; |
|
| 85 | + $this->description = $description; |
|
| 86 | + $this->formatter = $formatter; |
|
| 87 | + $this->resolver = $resolver; |
|
| 88 | + $this->caps = $caps; |
|
| 89 | + |
|
| 90 | + $this->use_for_input = true; |
|
| 91 | + $this->use_for_output = true; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @return array |
|
| 97 | + */ |
|
| 98 | + public function caps() |
|
| 99 | + { |
|
| 100 | + return $this->caps; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function description() |
|
| 108 | + { |
|
| 109 | + return $this->description; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | + public function key() |
|
| 117 | + { |
|
| 118 | + return $this->key; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + public function name() |
|
| 126 | + { |
|
| 127 | + return $this->name; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return string|string[] |
|
| 133 | + */ |
|
| 134 | + public function type() |
|
| 135 | + { |
|
| 136 | + return $this->type; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Convert the field to array to be |
|
| 142 | + * able to pass as config to WP GraphQL |
|
| 143 | + * |
|
| 144 | + * @return array |
|
| 145 | + */ |
|
| 146 | + public function toArray() |
|
| 147 | + { |
|
| 148 | + return get_object_vars($this); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Sets the value for use_for_input. |
|
| 154 | + * |
|
| 155 | 155 | * @param bool $use_for_input |
| 156 | - * |
|
| 157 | - */ |
|
| 158 | - protected function setUseForInput($use_for_input) |
|
| 159 | - { |
|
| 160 | - $this->use_for_input = (bool) $use_for_input; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Whether the field should be used for |
|
| 166 | - * mutation inputs. |
|
| 167 | - * |
|
| 168 | - * @return bool |
|
| 169 | - */ |
|
| 170 | - public function useForInput() |
|
| 171 | - { |
|
| 172 | - return (bool) $this->use_for_input; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Whether the field should be used for |
|
| 178 | - * query outputs. |
|
| 179 | - * |
|
| 180 | - * @return bool |
|
| 181 | - */ |
|
| 182 | - public function useForOutput() |
|
| 183 | - { |
|
| 184 | - return (bool) $this->use_for_output; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Sets the value for use_for_output |
|
| 190 | - * |
|
| 191 | - * @return array |
|
| 192 | - */ |
|
| 193 | - protected function setUseForOutput($use_for_output) |
|
| 194 | - { |
|
| 195 | - $this->use_for_output = (bool) $use_for_output; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Whether the field should resolve |
|
| 201 | - * based on the user caps etc. |
|
| 202 | - * |
|
| 203 | - * @return boolean |
|
| 204 | - */ |
|
| 205 | - public function shouldResolve() |
|
| 206 | - { |
|
| 207 | - foreach ($this->caps as $cap) { |
|
| 208 | - if (! current_user_can($cap)) { |
|
| 209 | - return false; |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - return true; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Whether the field has an explicit resolver set. |
|
| 218 | - * |
|
| 219 | - * @return boolean |
|
| 220 | - */ |
|
| 221 | - public function hasInternalResolver() |
|
| 222 | - { |
|
| 223 | - return is_callable($this->resolver); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * Whether the field has an explicit resolver set. |
|
| 229 | - * |
|
| 230 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
| 231 | - * @param array $args The inputArgs on the field |
|
| 232 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 233 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 234 | - * @return mixed |
|
| 235 | - * @throws LogicException |
|
| 236 | - */ |
|
| 237 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
| 238 | - { |
|
| 239 | - if (! $this->hasInternalResolver()) { |
|
| 240 | - throw new LogicException('GraphQLField has no internal resolver.'); |
|
| 241 | - } |
|
| 242 | - // dynamic methods using $this don't play nice |
|
| 243 | - // so capture resolver to a single var first |
|
| 244 | - $resolver = $this->resolver; |
|
| 245 | - return $resolver($source, $args, $context, $info); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Checks if the format callback is set. |
|
| 251 | - * If yes, then uses it to format the value. |
|
| 252 | - * |
|
| 253 | - * @param mixed $value |
|
| 254 | - * @return mixed The formatted value. |
|
| 255 | - */ |
|
| 256 | - public function mayBeFormatValue($value) |
|
| 257 | - { |
|
| 258 | - if (is_callable($this->formatter)) { |
|
| 259 | - // dynamic methods using $this don't play nice |
|
| 260 | - // so capture formatter to a single var first |
|
| 261 | - $formatter = $this->formatter; |
|
| 262 | - return $formatter($value); |
|
| 263 | - } |
|
| 264 | - return $value; |
|
| 265 | - } |
|
| 156 | + * |
|
| 157 | + */ |
|
| 158 | + protected function setUseForInput($use_for_input) |
|
| 159 | + { |
|
| 160 | + $this->use_for_input = (bool) $use_for_input; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Whether the field should be used for |
|
| 166 | + * mutation inputs. |
|
| 167 | + * |
|
| 168 | + * @return bool |
|
| 169 | + */ |
|
| 170 | + public function useForInput() |
|
| 171 | + { |
|
| 172 | + return (bool) $this->use_for_input; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Whether the field should be used for |
|
| 178 | + * query outputs. |
|
| 179 | + * |
|
| 180 | + * @return bool |
|
| 181 | + */ |
|
| 182 | + public function useForOutput() |
|
| 183 | + { |
|
| 184 | + return (bool) $this->use_for_output; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Sets the value for use_for_output |
|
| 190 | + * |
|
| 191 | + * @return array |
|
| 192 | + */ |
|
| 193 | + protected function setUseForOutput($use_for_output) |
|
| 194 | + { |
|
| 195 | + $this->use_for_output = (bool) $use_for_output; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Whether the field should resolve |
|
| 201 | + * based on the user caps etc. |
|
| 202 | + * |
|
| 203 | + * @return boolean |
|
| 204 | + */ |
|
| 205 | + public function shouldResolve() |
|
| 206 | + { |
|
| 207 | + foreach ($this->caps as $cap) { |
|
| 208 | + if (! current_user_can($cap)) { |
|
| 209 | + return false; |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + return true; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Whether the field has an explicit resolver set. |
|
| 218 | + * |
|
| 219 | + * @return boolean |
|
| 220 | + */ |
|
| 221 | + public function hasInternalResolver() |
|
| 222 | + { |
|
| 223 | + return is_callable($this->resolver); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * Whether the field has an explicit resolver set. |
|
| 229 | + * |
|
| 230 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
| 231 | + * @param array $args The inputArgs on the field |
|
| 232 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 233 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 234 | + * @return mixed |
|
| 235 | + * @throws LogicException |
|
| 236 | + */ |
|
| 237 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
| 238 | + { |
|
| 239 | + if (! $this->hasInternalResolver()) { |
|
| 240 | + throw new LogicException('GraphQLField has no internal resolver.'); |
|
| 241 | + } |
|
| 242 | + // dynamic methods using $this don't play nice |
|
| 243 | + // so capture resolver to a single var first |
|
| 244 | + $resolver = $this->resolver; |
|
| 245 | + return $resolver($source, $args, $context, $info); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Checks if the format callback is set. |
|
| 251 | + * If yes, then uses it to format the value. |
|
| 252 | + * |
|
| 253 | + * @param mixed $value |
|
| 254 | + * @return mixed The formatted value. |
|
| 255 | + */ |
|
| 256 | + public function mayBeFormatValue($value) |
|
| 257 | + { |
|
| 258 | + if (is_callable($this->formatter)) { |
|
| 259 | + // dynamic methods using $this don't play nice |
|
| 260 | + // so capture formatter to a single var first |
|
| 261 | + $formatter = $this->formatter; |
|
| 262 | + return $formatter($value); |
|
| 263 | + } |
|
| 264 | + return $value; |
|
| 265 | + } |
|
| 266 | 266 | } |
@@ -34,108 +34,108 @@ discard block |
||
| 34 | 34 | class TypesManager |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var TypeCollection|TypeInterface[] $types |
|
| 39 | - */ |
|
| 40 | - private $types; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * TypesManager constructor. |
|
| 45 | - * |
|
| 46 | - * @param TypeCollection|TypeInterface[] $types |
|
| 47 | - */ |
|
| 48 | - public function __construct(TypeCollection $types) |
|
| 49 | - { |
|
| 50 | - $this->types = $types; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @throws CollectionDetailsException |
|
| 56 | - * @throws CollectionLoaderException |
|
| 57 | - * @since $VID:$ |
|
| 58 | - */ |
|
| 59 | - public function init() |
|
| 60 | - { |
|
| 61 | - $this->types->loadTypes(); |
|
| 62 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - public function configureTypes() |
|
| 67 | - { |
|
| 68 | - // loop through the collection of types and register their fields |
|
| 69 | - foreach ($this->types as $type) { |
|
| 70 | - if ($type->isCustomPostType()) { |
|
| 71 | - $this->extendCustomPostType($type); |
|
| 72 | - } else { |
|
| 73 | - $this->registerType($type); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - public function extendCustomPostType($type) |
|
| 80 | - { |
|
| 81 | - $typeName = $type->name(); |
|
| 82 | - |
|
| 83 | - foreach ($type->fields() as $field) { |
|
| 84 | - |
|
| 85 | - $fieldName = $field->name(); |
|
| 86 | - |
|
| 87 | - $config = $field->toArray(); |
|
| 88 | - |
|
| 89 | - if ($field->useForInput()) { |
|
| 90 | - // Register input fields for existing mutations. |
|
| 91 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
| 92 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ($field->useForOutput()) { |
|
| 96 | - $config['resolve'] = [$type, 'resolveField']; |
|
| 97 | - // Register fields for queries. |
|
| 98 | - register_graphql_field($typeName, $fieldName, $config); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - public function registerType($type) |
|
| 105 | - { |
|
| 106 | - $outputFields = []; |
|
| 107 | - $inputFields = []; |
|
| 108 | - |
|
| 109 | - foreach ($type->fields() as $field) { |
|
| 110 | - |
|
| 111 | - $fieldName = $field->name(); |
|
| 112 | - |
|
| 113 | - $config = $field->toArray(); |
|
| 114 | - |
|
| 115 | - if ($field->useForInput()) { |
|
| 116 | - $inputFields[$fieldName] = $config; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($field->useForOutput()) { |
|
| 120 | - $config['resolve'] = [$type, 'resolveField']; |
|
| 121 | - $outputFields[$fieldName] = $config; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $typeName = $type->name(); |
|
| 126 | - |
|
| 127 | - if (! empty($outputFields)) { |
|
| 128 | - // Register the object type. |
|
| 129 | - register_graphql_object_type( |
|
| 130 | - $typeName, |
|
| 131 | - [ |
|
| 132 | - 'description' => $type->description(), |
|
| 133 | - 'fields' => $outputFields, |
|
| 134 | - ] |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /* register_graphql_mutation( |
|
| 37 | + /** |
|
| 38 | + * @var TypeCollection|TypeInterface[] $types |
|
| 39 | + */ |
|
| 40 | + private $types; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * TypesManager constructor. |
|
| 45 | + * |
|
| 46 | + * @param TypeCollection|TypeInterface[] $types |
|
| 47 | + */ |
|
| 48 | + public function __construct(TypeCollection $types) |
|
| 49 | + { |
|
| 50 | + $this->types = $types; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @throws CollectionDetailsException |
|
| 56 | + * @throws CollectionLoaderException |
|
| 57 | + * @since $VID:$ |
|
| 58 | + */ |
|
| 59 | + public function init() |
|
| 60 | + { |
|
| 61 | + $this->types->loadTypes(); |
|
| 62 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + public function configureTypes() |
|
| 67 | + { |
|
| 68 | + // loop through the collection of types and register their fields |
|
| 69 | + foreach ($this->types as $type) { |
|
| 70 | + if ($type->isCustomPostType()) { |
|
| 71 | + $this->extendCustomPostType($type); |
|
| 72 | + } else { |
|
| 73 | + $this->registerType($type); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + public function extendCustomPostType($type) |
|
| 80 | + { |
|
| 81 | + $typeName = $type->name(); |
|
| 82 | + |
|
| 83 | + foreach ($type->fields() as $field) { |
|
| 84 | + |
|
| 85 | + $fieldName = $field->name(); |
|
| 86 | + |
|
| 87 | + $config = $field->toArray(); |
|
| 88 | + |
|
| 89 | + if ($field->useForInput()) { |
|
| 90 | + // Register input fields for existing mutations. |
|
| 91 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
| 92 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ($field->useForOutput()) { |
|
| 96 | + $config['resolve'] = [$type, 'resolveField']; |
|
| 97 | + // Register fields for queries. |
|
| 98 | + register_graphql_field($typeName, $fieldName, $config); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + public function registerType($type) |
|
| 105 | + { |
|
| 106 | + $outputFields = []; |
|
| 107 | + $inputFields = []; |
|
| 108 | + |
|
| 109 | + foreach ($type->fields() as $field) { |
|
| 110 | + |
|
| 111 | + $fieldName = $field->name(); |
|
| 112 | + |
|
| 113 | + $config = $field->toArray(); |
|
| 114 | + |
|
| 115 | + if ($field->useForInput()) { |
|
| 116 | + $inputFields[$fieldName] = $config; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($field->useForOutput()) { |
|
| 120 | + $config['resolve'] = [$type, 'resolveField']; |
|
| 121 | + $outputFields[$fieldName] = $config; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $typeName = $type->name(); |
|
| 126 | + |
|
| 127 | + if (! empty($outputFields)) { |
|
| 128 | + // Register the object type. |
|
| 129 | + register_graphql_object_type( |
|
| 130 | + $typeName, |
|
| 131 | + [ |
|
| 132 | + 'description' => $type->description(), |
|
| 133 | + 'fields' => $outputFields, |
|
| 134 | + ] |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /* register_graphql_mutation( |
|
| 139 | 139 | 'create' . $typeName, |
| 140 | 140 | [ |
| 141 | 141 | 'inputFields' => $inputFields, |
@@ -152,5 +152,5 @@ discard block |
||
| 152 | 152 | 'mutateAndGetPayload' => [$type, 'mutateAndGetPayload'], |
| 153 | 153 | ] |
| 154 | 154 | ); */ |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | \ No newline at end of file |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | if ($field->useForInput()) { |
| 90 | 90 | // Register input fields for existing mutations. |
| 91 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
| 92 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
| 91 | + register_graphql_field('Update'.$typeName.'Input', $fieldName, $config); |
|
| 92 | + register_graphql_field('Create'.$typeName.'Input', $fieldName, $config); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if ($field->useForOutput()) { |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $typeName = $type->name(); |
| 126 | 126 | |
| 127 | - if (! empty($outputFields)) { |
|
| 127 | + if ( ! empty($outputFields)) { |
|
| 128 | 128 | // Register the object type. |
| 129 | 129 | register_graphql_object_type( |
| 130 | 130 | $typeName, |
@@ -46,227 +46,227 @@ |
||
| 46 | 46 | abstract class TypeBase implements TypeInterface |
| 47 | 47 | { |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var EEM_Base $model |
|
| 51 | - */ |
|
| 52 | - protected $model; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var string $name |
|
| 56 | - */ |
|
| 57 | - protected $name = ''; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var string $description |
|
| 61 | - */ |
|
| 62 | - protected $description = ''; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @var GraphQLField[] $fields |
|
| 66 | - */ |
|
| 67 | - protected $fields = []; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @var array $graphql_to_model_map |
|
| 71 | - */ |
|
| 72 | - protected $graphql_to_model_map = []; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @var FieldResolver $field_resolver |
|
| 76 | - */ |
|
| 77 | - protected $field_resolver; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @var bool $is_custom_post_type |
|
| 81 | - */ |
|
| 82 | - protected $is_custom_post_type = false; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * TypeBase constructor. |
|
| 86 | - */ |
|
| 87 | - public function __construct() |
|
| 88 | - { |
|
| 89 | - $this->setFields($this->getFields()); |
|
| 90 | - $this->field_resolver = new FieldResolver( |
|
| 91 | - $this->model, |
|
| 92 | - $this->getFieldsForResolver() |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @return GraphQLField[] |
|
| 99 | - * @since $VID:$ |
|
| 100 | - */ |
|
| 101 | - abstract protected function getFields(); |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - public function name() |
|
| 108 | - { |
|
| 109 | - return $this->name; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @param string $name |
|
| 115 | - */ |
|
| 116 | - protected function setName($name) |
|
| 117 | - { |
|
| 118 | - $this->name = $name; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return string |
|
| 124 | - */ |
|
| 125 | - public function description() |
|
| 126 | - { |
|
| 127 | - return $this->description; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @param string $description |
|
| 133 | - */ |
|
| 134 | - protected function setDescription($description) |
|
| 135 | - { |
|
| 136 | - $this->description = $description; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return GraphQLField[] |
|
| 142 | - * @since $VID:$ |
|
| 143 | - */ |
|
| 144 | - public function fields() |
|
| 145 | - { |
|
| 146 | - return (array) $this->fields; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @param GraphQLField[] $fields |
|
| 152 | - */ |
|
| 153 | - protected function setFields(array $fields) |
|
| 154 | - { |
|
| 155 | - foreach ($fields as $field) { |
|
| 156 | - if ($field instanceof GraphQLField) { |
|
| 157 | - $this->fields[] = $field; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Creates a key map for internal resolver. |
|
| 165 | - * @return array |
|
| 166 | - * @since $VID:$ |
|
| 167 | - */ |
|
| 168 | - public function getFieldsForResolver() |
|
| 169 | - { |
|
| 170 | - $fields = []; |
|
| 171 | - foreach ($this->fields() as $field) { |
|
| 172 | - if ($field->useForOutput()) { |
|
| 173 | - $fields[$field->name()] = $field; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - return $fields; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return bool |
|
| 182 | - */ |
|
| 183 | - public function isCustomPostType() |
|
| 184 | - { |
|
| 185 | - return $this->is_custom_post_type; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @param bool $is_custom_post_type |
|
| 191 | - */ |
|
| 192 | - protected function setIsCustomPostType($is_custom_post_type) |
|
| 193 | - { |
|
| 194 | - $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @param int $value |
|
| 200 | - * @return int |
|
| 201 | - * @since $VID:$ |
|
| 202 | - */ |
|
| 203 | - public function parseInfiniteValue($value) |
|
| 204 | - { |
|
| 205 | - $value = trim($value); |
|
| 206 | - return $value === null |
|
| 207 | - || $value === '' |
|
| 208 | - || $value === '∞' |
|
| 209 | - || $value === 'INF' |
|
| 210 | - || $value === INF |
|
| 211 | - || $value === EE_INF |
|
| 212 | - || is_infinite((float) $value) |
|
| 213 | - ? -1 |
|
| 214 | - : $value; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * @param mixed $source |
|
| 220 | - * @return EE_Base_Class|null |
|
| 221 | - * @since $VID:$ |
|
| 222 | - */ |
|
| 223 | - private function getModel($source) |
|
| 224 | - { |
|
| 225 | - // If it comes from a custom connection |
|
| 226 | - // where the $source is already instantiated. |
|
| 227 | - if ($source instanceof EE_Base_Class) { |
|
| 228 | - return $source; |
|
| 229 | - } |
|
| 230 | - return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
| 236 | - * @param array $args The inputArgs on the field |
|
| 237 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 238 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 239 | - * @return string |
|
| 240 | - * @throws EE_Error |
|
| 241 | - * @throws InvalidDataTypeException |
|
| 242 | - * @throws InvalidInterfaceException |
|
| 243 | - * @throws UnexpectedEntityException |
|
| 244 | - * @throws UserError |
|
| 245 | - * @throws InvalidArgumentException |
|
| 246 | - * @throws ReflectionException |
|
| 247 | - * @since $VID:$ |
|
| 248 | - */ |
|
| 249 | - public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
| 250 | - { |
|
| 251 | - $source = $this->getModel($source); |
|
| 252 | - if ($source instanceof EE_Base_Class) { |
|
| 253 | - return $this->field_resolver->resolve($source, $args, $context, $info); |
|
| 254 | - } |
|
| 255 | - return null; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * @param array $input The mutation input. |
|
| 261 | - * @param AppContext $context The AppContext passed down the GraphQL tree. |
|
| 262 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree. |
|
| 263 | - * @return mixed |
|
| 264 | - * @throws UserError |
|
| 265 | - * @throws InvalidArgumentException |
|
| 266 | - * @throws ReflectionException |
|
| 267 | - * @since $VID:$ |
|
| 268 | - */ |
|
| 269 | - public function mutateAndGetPayload($input, AppContext $context, ResolveInfo $info) { |
|
| 270 | - |
|
| 271 | - } |
|
| 49 | + /** |
|
| 50 | + * @var EEM_Base $model |
|
| 51 | + */ |
|
| 52 | + protected $model; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var string $name |
|
| 56 | + */ |
|
| 57 | + protected $name = ''; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var string $description |
|
| 61 | + */ |
|
| 62 | + protected $description = ''; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @var GraphQLField[] $fields |
|
| 66 | + */ |
|
| 67 | + protected $fields = []; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @var array $graphql_to_model_map |
|
| 71 | + */ |
|
| 72 | + protected $graphql_to_model_map = []; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @var FieldResolver $field_resolver |
|
| 76 | + */ |
|
| 77 | + protected $field_resolver; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @var bool $is_custom_post_type |
|
| 81 | + */ |
|
| 82 | + protected $is_custom_post_type = false; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * TypeBase constructor. |
|
| 86 | + */ |
|
| 87 | + public function __construct() |
|
| 88 | + { |
|
| 89 | + $this->setFields($this->getFields()); |
|
| 90 | + $this->field_resolver = new FieldResolver( |
|
| 91 | + $this->model, |
|
| 92 | + $this->getFieldsForResolver() |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @return GraphQLField[] |
|
| 99 | + * @since $VID:$ |
|
| 100 | + */ |
|
| 101 | + abstract protected function getFields(); |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + public function name() |
|
| 108 | + { |
|
| 109 | + return $this->name; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @param string $name |
|
| 115 | + */ |
|
| 116 | + protected function setName($name) |
|
| 117 | + { |
|
| 118 | + $this->name = $name; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return string |
|
| 124 | + */ |
|
| 125 | + public function description() |
|
| 126 | + { |
|
| 127 | + return $this->description; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @param string $description |
|
| 133 | + */ |
|
| 134 | + protected function setDescription($description) |
|
| 135 | + { |
|
| 136 | + $this->description = $description; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return GraphQLField[] |
|
| 142 | + * @since $VID:$ |
|
| 143 | + */ |
|
| 144 | + public function fields() |
|
| 145 | + { |
|
| 146 | + return (array) $this->fields; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param GraphQLField[] $fields |
|
| 152 | + */ |
|
| 153 | + protected function setFields(array $fields) |
|
| 154 | + { |
|
| 155 | + foreach ($fields as $field) { |
|
| 156 | + if ($field instanceof GraphQLField) { |
|
| 157 | + $this->fields[] = $field; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Creates a key map for internal resolver. |
|
| 165 | + * @return array |
|
| 166 | + * @since $VID:$ |
|
| 167 | + */ |
|
| 168 | + public function getFieldsForResolver() |
|
| 169 | + { |
|
| 170 | + $fields = []; |
|
| 171 | + foreach ($this->fields() as $field) { |
|
| 172 | + if ($field->useForOutput()) { |
|
| 173 | + $fields[$field->name()] = $field; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + return $fields; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * @return bool |
|
| 182 | + */ |
|
| 183 | + public function isCustomPostType() |
|
| 184 | + { |
|
| 185 | + return $this->is_custom_post_type; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @param bool $is_custom_post_type |
|
| 191 | + */ |
|
| 192 | + protected function setIsCustomPostType($is_custom_post_type) |
|
| 193 | + { |
|
| 194 | + $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @param int $value |
|
| 200 | + * @return int |
|
| 201 | + * @since $VID:$ |
|
| 202 | + */ |
|
| 203 | + public function parseInfiniteValue($value) |
|
| 204 | + { |
|
| 205 | + $value = trim($value); |
|
| 206 | + return $value === null |
|
| 207 | + || $value === '' |
|
| 208 | + || $value === '∞' |
|
| 209 | + || $value === 'INF' |
|
| 210 | + || $value === INF |
|
| 211 | + || $value === EE_INF |
|
| 212 | + || is_infinite((float) $value) |
|
| 213 | + ? -1 |
|
| 214 | + : $value; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * @param mixed $source |
|
| 220 | + * @return EE_Base_Class|null |
|
| 221 | + * @since $VID:$ |
|
| 222 | + */ |
|
| 223 | + private function getModel($source) |
|
| 224 | + { |
|
| 225 | + // If it comes from a custom connection |
|
| 226 | + // where the $source is already instantiated. |
|
| 227 | + if ($source instanceof EE_Base_Class) { |
|
| 228 | + return $source; |
|
| 229 | + } |
|
| 230 | + return $source instanceof Post ? $this->model->get_one_by_ID($source->ID) : null; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
| 236 | + * @param array $args The inputArgs on the field |
|
| 237 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 238 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 239 | + * @return string |
|
| 240 | + * @throws EE_Error |
|
| 241 | + * @throws InvalidDataTypeException |
|
| 242 | + * @throws InvalidInterfaceException |
|
| 243 | + * @throws UnexpectedEntityException |
|
| 244 | + * @throws UserError |
|
| 245 | + * @throws InvalidArgumentException |
|
| 246 | + * @throws ReflectionException |
|
| 247 | + * @since $VID:$ |
|
| 248 | + */ |
|
| 249 | + public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
| 250 | + { |
|
| 251 | + $source = $this->getModel($source); |
|
| 252 | + if ($source instanceof EE_Base_Class) { |
|
| 253 | + return $this->field_resolver->resolve($source, $args, $context, $info); |
|
| 254 | + } |
|
| 255 | + return null; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * @param array $input The mutation input. |
|
| 261 | + * @param AppContext $context The AppContext passed down the GraphQL tree. |
|
| 262 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree. |
|
| 263 | + * @return mixed |
|
| 264 | + * @throws UserError |
|
| 265 | + * @throws InvalidArgumentException |
|
| 266 | + * @throws ReflectionException |
|
| 267 | + * @since $VID:$ |
|
| 268 | + */ |
|
| 269 | + public function mutateAndGetPayload($input, AppContext $context, ResolveInfo $info) { |
|
| 270 | + |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | \ No newline at end of file |