@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\domain\services\graphql\fields; |
| 3 | 3 | |
| 4 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
| 5 | -use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
| 6 | 4 | use InvalidArgumentException; |
| 7 | 5 | |
| 8 | 6 | /** |
@@ -14,123 +14,123 @@ |
||
| 14 | 14 | class GraphQLField |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var mixed $name |
|
| 19 | - */ |
|
| 20 | - protected $name; |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @param string $name |
|
| 25 | - * @param array $config |
|
| 26 | - * @throws InvalidArgumentException |
|
| 27 | - */ |
|
| 28 | - public function __construct($name, array $config = []) |
|
| 29 | - { |
|
| 17 | + /** |
|
| 18 | + * @var mixed $name |
|
| 19 | + */ |
|
| 20 | + protected $name; |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @param string $name |
|
| 25 | + * @param array $config |
|
| 26 | + * @throws InvalidArgumentException |
|
| 27 | + */ |
|
| 28 | + public function __construct($name, array $config = []) |
|
| 29 | + { |
|
| 30 | 30 | $this->name = $name; |
| 31 | 31 | $this->setProps($config); |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param array $config |
|
| 37 | - * @throws InvalidArgumentException |
|
| 38 | - */ |
|
| 39 | - public function setProps(array $config) |
|
| 40 | - { |
|
| 35 | + /** |
|
| 36 | + * @param array $config |
|
| 37 | + * @throws InvalidArgumentException |
|
| 38 | + */ |
|
| 39 | + public function setProps(array $config) |
|
| 40 | + { |
|
| 41 | 41 | foreach ($config as $key => $value) { |
| 42 | 42 | $this->{$key} = $value; |
| 43 | 43 | } |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get the field name. |
|
| 47 | + /** |
|
| 48 | + * Get the field name. |
|
| 49 | 49 | * |
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function name() |
|
| 53 | - { |
|
| 54 | - return $this->name; |
|
| 55 | - } |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function name() |
|
| 53 | + { |
|
| 54 | + return $this->name; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Get the model key of the field. |
|
| 58 | + /** |
|
| 59 | + * Get the model key of the field. |
|
| 60 | 60 | * |
| 61 | - * @return string|null |
|
| 62 | - */ |
|
| 63 | - public function key() |
|
| 64 | - { |
|
| 61 | + * @return string|null |
|
| 62 | + */ |
|
| 63 | + public function key() |
|
| 64 | + { |
|
| 65 | 65 | if (isset($this->key)) { |
| 66 | 66 | return $this->key; |
| 67 | 67 | } |
| 68 | 68 | return null; |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Get the caps required for the field. |
|
| 72 | + /** |
|
| 73 | + * Get the caps required for the field. |
|
| 74 | 74 | * |
| 75 | - * @return array |
|
| 76 | - */ |
|
| 77 | - public function caps() |
|
| 78 | - { |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | + public function caps() |
|
| 78 | + { |
|
| 79 | 79 | if (isset($this->caps)) { |
| 80 | 80 | return (array) $this->caps; |
| 81 | 81 | } |
| 82 | 82 | return []; |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | - /** |
|
| 86 | + /** |
|
| 87 | 87 | * Whether the field should resolve |
| 88 | 88 | * based on the user caps etc. |
| 89 | - * @return boolean |
|
| 90 | - */ |
|
| 91 | - public function shouldResolve() |
|
| 92 | - { |
|
| 89 | + * @return boolean |
|
| 90 | + */ |
|
| 91 | + public function shouldResolve() |
|
| 92 | + { |
|
| 93 | 93 | foreach ($this->caps() as $cap) { |
| 94 | 94 | if (!current_user_can($cap)) { |
| 95 | 95 | return false; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | return true; |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | - /** |
|
| 102 | + /** |
|
| 103 | 103 | * Whether the field has an explicit resolver set. |
| 104 | - * @return boolean |
|
| 105 | - */ |
|
| 106 | - public function hasInternalResolver() |
|
| 107 | - { |
|
| 104 | + * @return boolean |
|
| 105 | + */ |
|
| 106 | + public function hasInternalResolver() |
|
| 107 | + { |
|
| 108 | 108 | return isset($this->resolve) && is_callable($this->resolve); |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - /** |
|
| 112 | + /** |
|
| 113 | 113 | * Checks if the format callback is set. |
| 114 | 114 | * If yes, then uses it to format the value. |
| 115 | - * @param mixed $value |
|
| 116 | - * @return mixed The formatted value. |
|
| 117 | - */ |
|
| 118 | - public function mayBeFormatValue($value) |
|
| 119 | - { |
|
| 115 | + * @param mixed $value |
|
| 116 | + * @return mixed The formatted value. |
|
| 117 | + */ |
|
| 118 | + public function mayBeFormatValue($value) |
|
| 119 | + { |
|
| 120 | 120 | if (isset($this->formatCallback) && is_callable($this->formatCallback)) { |
| 121 | 121 | return call_user_func($this->formatCallback, $value); |
| 122 | 122 | } |
| 123 | 123 | return $value; |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | - /** |
|
| 127 | + /** |
|
| 128 | 128 | * Convert the field to array to be |
| 129 | 129 | * able to pass as config to WP GraphQL |
| 130 | - * @return array |
|
| 131 | - */ |
|
| 132 | - public function toArray() |
|
| 133 | - { |
|
| 130 | + * @return array |
|
| 131 | + */ |
|
| 132 | + public function toArray() |
|
| 133 | + { |
|
| 134 | 134 | return get_object_vars($this); |
| 135 | - } |
|
| 135 | + } |
|
| 136 | 136 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function __construct($name, array $config = []) |
| 29 | 29 | { |
| 30 | - $this->name = $name; |
|
| 30 | + $this->name = $name; |
|
| 31 | 31 | $this->setProps($config); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | public function shouldResolve() |
| 92 | 92 | { |
| 93 | 93 | foreach ($this->caps() as $cap) { |
| 94 | - if (!current_user_can($cap)) { |
|
| 94 | + if ( ! current_user_can($cap)) { |
|
| 95 | 95 | return false; |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * FieldResolver constructor. |
| 57 | 57 | * |
| 58 | - * @param mixed $model The model instance. |
|
| 58 | + * @param EEM_Base $model The model instance. |
|
| 59 | 59 | * @param array $fields The fields registered for the type. |
| 60 | 60 | */ |
| 61 | 61 | public function __construct($model, array $fields ) |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
| 68 | + * @param EE_Base_Class|null $source The source that's passed down the GraphQL queries |
|
| 69 | 69 | * @param array $args The inputArgs on the field |
| 70 | 70 | * @param AppContext $context The AppContext passed down the GraphQL tree |
| 71 | 71 | * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * @param mixed $source The source instance. |
| 189 | - * @return int |
|
| 189 | + * @return EE_Base_Class|null |
|
| 190 | 190 | * @since $VID:$ |
| 191 | 191 | */ |
| 192 | 192 | public function resolveState($source) |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | 211 | * @param mixed $source The source instance. |
| 212 | - * @return int |
|
| 212 | + * @return EE_Base_Class|null |
|
| 213 | 213 | * @since $VID:$ |
| 214 | 214 | */ |
| 215 | 215 | public function resolveCountry($source) |
@@ -2,7 +2,6 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace EventEspresso\core\domain\services\graphql\resolvers; |
| 4 | 4 | |
| 5 | -use EEM_Base; |
|
| 6 | 5 | use EE_Base_Class; |
| 7 | 6 | use EE_Event; |
| 8 | 7 | use EE_Venue; |
@@ -10,22 +9,17 @@ discard block |
||
| 10 | 9 | use EE_Ticket; |
| 11 | 10 | use EE_State; |
| 12 | 11 | use EEM_State; |
| 13 | -use EE_Country; |
|
| 14 | 12 | use EEM_Country; |
| 15 | 13 | use EE_Error; |
| 16 | - |
|
| 17 | 14 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 18 | 15 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 19 | -use EventEspresso\core\services\graphql\TypeBase; |
|
| 20 | 16 | use EventEspresso\core\services\graphql\ResolverBase; |
| 21 | 17 | use EventEspresso\core\domain\services\graphql\fields\GraphQLField; |
| 22 | 18 | use InvalidArgumentException; |
| 23 | 19 | use ReflectionException; |
| 24 | - |
|
| 25 | 20 | use WPGraphQL\Data\DataSource; |
| 26 | 21 | use GraphQL\Deferred; |
| 27 | 22 | use GraphQL\Error\UserError; |
| 28 | -use WPGraphQL\Model\Post; |
|
| 29 | 23 | use GraphQL\Type\Definition\ResolveInfo; |
| 30 | 24 | use WPGraphQL\AppContext; |
| 31 | 25 | |
@@ -41,194 +41,194 @@ |
||
| 41 | 41 | class FieldResolver extends ResolverBase |
| 42 | 42 | { |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var mixed $model |
|
| 46 | - */ |
|
| 47 | - protected $model; |
|
| 44 | + /** |
|
| 45 | + * @var mixed $model |
|
| 46 | + */ |
|
| 47 | + protected $model; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var array $fields. |
|
| 51 | - */ |
|
| 52 | - protected $fields; |
|
| 49 | + /** |
|
| 50 | + * @var array $fields. |
|
| 51 | + */ |
|
| 52 | + protected $fields; |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * FieldResolver constructor. |
|
| 57 | - * |
|
| 55 | + /** |
|
| 56 | + * FieldResolver constructor. |
|
| 57 | + * |
|
| 58 | 58 | * @param mixed $model The model instance. |
| 59 | - * @param array $fields The fields registered for the type. |
|
| 60 | - */ |
|
| 61 | - public function __construct($model, array $fields ) |
|
| 62 | - { |
|
| 59 | + * @param array $fields The fields registered for the type. |
|
| 60 | + */ |
|
| 61 | + public function __construct($model, array $fields ) |
|
| 62 | + { |
|
| 63 | 63 | $this->model = $model; |
| 64 | 64 | $this->fields = $fields; |
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
| 69 | - * @param array $args The inputArgs on the field |
|
| 70 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 71 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 72 | - * @return string |
|
| 73 | - * @since $VID:$ |
|
| 74 | - */ |
|
| 75 | - public function resolve($source, $args, AppContext $context, ResolveInfo $info) |
|
| 76 | - { |
|
| 77 | - $fieldName = $info->fieldName; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
| 69 | + * @param array $args The inputArgs on the field |
|
| 70 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 71 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 72 | + * @return string |
|
| 73 | + * @since $VID:$ |
|
| 74 | + */ |
|
| 75 | + public function resolve($source, $args, AppContext $context, ResolveInfo $info) |
|
| 76 | + { |
|
| 77 | + $fieldName = $info->fieldName; |
|
| 78 | 78 | |
| 79 | - // Field should exist in teh registered fields |
|
| 79 | + // Field should exist in teh registered fields |
|
| 80 | 80 | if (isset($this->fields[$fieldName]) && $this->fields[$fieldName] instanceof GraphQLField) { |
| 81 | - $field = $this->fields[$fieldName]; |
|
| 82 | - |
|
| 83 | - // check if the field should be resolved. |
|
| 84 | - if (!$field->shouldResolve()) { |
|
| 85 | - return null; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // Give priority to the internal resolver. |
|
| 89 | - if ($field->hasInternalResolver()) { |
|
| 90 | - return call_user_func($field->resolve, $source, $args, $context, $info); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Check if the field has a key mapped to model. |
|
| 94 | - if (!empty($field->key())) { |
|
| 95 | - $value = $source->{$field->key()}(); |
|
| 96 | - return $field->mayBeFormatValue($value); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - switch ($fieldName) { |
|
| 100 | - case 'parent': |
|
| 101 | - return $this->resolveParent($source); |
|
| 102 | - case 'event': |
|
| 103 | - return $this->resolveEvent($source, $args, $context); |
|
| 104 | - case 'wpUser': |
|
| 105 | - return $this->resolveWpUser($source, $args, $context); |
|
| 106 | - case 'state': // Venue |
|
| 107 | - return $this->resolveState($source); |
|
| 108 | - case 'country': // State, Venue |
|
| 109 | - return $this->resolveCountry($source); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - return null; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @param mixed $source |
|
| 118 | - * @param $args |
|
| 119 | - * @param $context |
|
| 120 | - * @return Deferred|null |
|
| 121 | - * @throws EE_Error |
|
| 122 | - * @throws InvalidArgumentException |
|
| 123 | - * @throws InvalidDataTypeException |
|
| 124 | - * @throws InvalidInterfaceException |
|
| 125 | - * @throws ReflectionException |
|
| 126 | - * @throws UserError |
|
| 127 | - * @since $VID:$ |
|
| 128 | - */ |
|
| 129 | - public function resolveWpUser($source, $args, $context) |
|
| 130 | - { |
|
| 131 | - $user_id = $source->wp_user(); |
|
| 132 | - return $user_id |
|
| 133 | - ? DataSource::resolve_user($user_id, $context) |
|
| 134 | - : null; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param mixed $source |
|
| 140 | - * @return EE_Base_Class|null |
|
| 141 | - * @throws EE_Error |
|
| 142 | - * @throws InvalidArgumentException |
|
| 143 | - * @throws InvalidDataTypeException |
|
| 144 | - * @throws InvalidInterfaceException |
|
| 145 | - * @throws ReflectionException |
|
| 146 | - * @since $VID:$ |
|
| 147 | - */ |
|
| 148 | - public function resolveParent($source) |
|
| 149 | - { |
|
| 150 | - return $this->model->get_one_by_ID($source->parent()); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @param mixed $source |
|
| 156 | - * @param $args |
|
| 157 | - * @param $context |
|
| 158 | - * @return Deferred|null |
|
| 159 | - * @throws EE_Error |
|
| 160 | - * @throws InvalidDataTypeException |
|
| 161 | - * @throws InvalidInterfaceException |
|
| 162 | - * @throws UserError |
|
| 163 | - * @throws InvalidArgumentException |
|
| 164 | - * @throws ReflectionException |
|
| 165 | - * @since $VID:$ |
|
| 166 | - */ |
|
| 167 | - public function resolveEvent($source, $args, $context) |
|
| 168 | - { |
|
| 169 | - switch (true) { |
|
| 170 | - case $source instanceof EE_Datetime: |
|
| 171 | - $event = $source->event(); |
|
| 172 | - break; |
|
| 173 | - case $source instanceof EE_Venue: |
|
| 174 | - case $source instanceof EE_Ticket: |
|
| 175 | - $event = $source->get_related_event(); |
|
| 176 | - break; |
|
| 177 | - default: |
|
| 178 | - $event = null; |
|
| 179 | - break; |
|
| 180 | - } |
|
| 181 | - return $event instanceof EE_Event |
|
| 182 | - ? DataSource::resolve_post_object($event->ID(), $context) |
|
| 183 | - : null; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @param mixed $source The source instance. |
|
| 189 | - * @return int |
|
| 190 | - * @since $VID:$ |
|
| 191 | - */ |
|
| 192 | - public function resolveState($source) |
|
| 193 | - { |
|
| 194 | - switch (true) { |
|
| 195 | - case $source instanceof EE_Venue: |
|
| 196 | - $state_id = $source->state_ID(); |
|
| 197 | - break; |
|
| 198 | - default: |
|
| 199 | - $state_id = null; |
|
| 200 | - break; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - if ($state_id) { |
|
| 204 | - return EEM_State::instance()->get_one_by_ID($state_id); |
|
| 205 | - } |
|
| 206 | - return null; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * @param mixed $source The source instance. |
|
| 212 | - * @return int |
|
| 213 | - * @since $VID:$ |
|
| 214 | - */ |
|
| 215 | - public function resolveCountry($source) |
|
| 216 | - { |
|
| 217 | - switch (true) { |
|
| 218 | - case $source instanceof EE_State: |
|
| 219 | - $country_iso = $source->country_iso(); |
|
| 220 | - break; |
|
| 221 | - case $source instanceof EE_Venue: |
|
| 222 | - $country_iso = $source->country_ID(); |
|
| 223 | - break; |
|
| 224 | - default: |
|
| 225 | - $country_iso = null; |
|
| 226 | - break; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if ($country_iso) { |
|
| 230 | - return EEM_Country::instance()->get_one_by_ID($country_iso); |
|
| 231 | - } |
|
| 232 | - return null; |
|
| 233 | - } |
|
| 81 | + $field = $this->fields[$fieldName]; |
|
| 82 | + |
|
| 83 | + // check if the field should be resolved. |
|
| 84 | + if (!$field->shouldResolve()) { |
|
| 85 | + return null; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // Give priority to the internal resolver. |
|
| 89 | + if ($field->hasInternalResolver()) { |
|
| 90 | + return call_user_func($field->resolve, $source, $args, $context, $info); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Check if the field has a key mapped to model. |
|
| 94 | + if (!empty($field->key())) { |
|
| 95 | + $value = $source->{$field->key()}(); |
|
| 96 | + return $field->mayBeFormatValue($value); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + switch ($fieldName) { |
|
| 100 | + case 'parent': |
|
| 101 | + return $this->resolveParent($source); |
|
| 102 | + case 'event': |
|
| 103 | + return $this->resolveEvent($source, $args, $context); |
|
| 104 | + case 'wpUser': |
|
| 105 | + return $this->resolveWpUser($source, $args, $context); |
|
| 106 | + case 'state': // Venue |
|
| 107 | + return $this->resolveState($source); |
|
| 108 | + case 'country': // State, Venue |
|
| 109 | + return $this->resolveCountry($source); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + return null; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @param mixed $source |
|
| 118 | + * @param $args |
|
| 119 | + * @param $context |
|
| 120 | + * @return Deferred|null |
|
| 121 | + * @throws EE_Error |
|
| 122 | + * @throws InvalidArgumentException |
|
| 123 | + * @throws InvalidDataTypeException |
|
| 124 | + * @throws InvalidInterfaceException |
|
| 125 | + * @throws ReflectionException |
|
| 126 | + * @throws UserError |
|
| 127 | + * @since $VID:$ |
|
| 128 | + */ |
|
| 129 | + public function resolveWpUser($source, $args, $context) |
|
| 130 | + { |
|
| 131 | + $user_id = $source->wp_user(); |
|
| 132 | + return $user_id |
|
| 133 | + ? DataSource::resolve_user($user_id, $context) |
|
| 134 | + : null; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param mixed $source |
|
| 140 | + * @return EE_Base_Class|null |
|
| 141 | + * @throws EE_Error |
|
| 142 | + * @throws InvalidArgumentException |
|
| 143 | + * @throws InvalidDataTypeException |
|
| 144 | + * @throws InvalidInterfaceException |
|
| 145 | + * @throws ReflectionException |
|
| 146 | + * @since $VID:$ |
|
| 147 | + */ |
|
| 148 | + public function resolveParent($source) |
|
| 149 | + { |
|
| 150 | + return $this->model->get_one_by_ID($source->parent()); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @param mixed $source |
|
| 156 | + * @param $args |
|
| 157 | + * @param $context |
|
| 158 | + * @return Deferred|null |
|
| 159 | + * @throws EE_Error |
|
| 160 | + * @throws InvalidDataTypeException |
|
| 161 | + * @throws InvalidInterfaceException |
|
| 162 | + * @throws UserError |
|
| 163 | + * @throws InvalidArgumentException |
|
| 164 | + * @throws ReflectionException |
|
| 165 | + * @since $VID:$ |
|
| 166 | + */ |
|
| 167 | + public function resolveEvent($source, $args, $context) |
|
| 168 | + { |
|
| 169 | + switch (true) { |
|
| 170 | + case $source instanceof EE_Datetime: |
|
| 171 | + $event = $source->event(); |
|
| 172 | + break; |
|
| 173 | + case $source instanceof EE_Venue: |
|
| 174 | + case $source instanceof EE_Ticket: |
|
| 175 | + $event = $source->get_related_event(); |
|
| 176 | + break; |
|
| 177 | + default: |
|
| 178 | + $event = null; |
|
| 179 | + break; |
|
| 180 | + } |
|
| 181 | + return $event instanceof EE_Event |
|
| 182 | + ? DataSource::resolve_post_object($event->ID(), $context) |
|
| 183 | + : null; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @param mixed $source The source instance. |
|
| 189 | + * @return int |
|
| 190 | + * @since $VID:$ |
|
| 191 | + */ |
|
| 192 | + public function resolveState($source) |
|
| 193 | + { |
|
| 194 | + switch (true) { |
|
| 195 | + case $source instanceof EE_Venue: |
|
| 196 | + $state_id = $source->state_ID(); |
|
| 197 | + break; |
|
| 198 | + default: |
|
| 199 | + $state_id = null; |
|
| 200 | + break; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + if ($state_id) { |
|
| 204 | + return EEM_State::instance()->get_one_by_ID($state_id); |
|
| 205 | + } |
|
| 206 | + return null; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * @param mixed $source The source instance. |
|
| 212 | + * @return int |
|
| 213 | + * @since $VID:$ |
|
| 214 | + */ |
|
| 215 | + public function resolveCountry($source) |
|
| 216 | + { |
|
| 217 | + switch (true) { |
|
| 218 | + case $source instanceof EE_State: |
|
| 219 | + $country_iso = $source->country_iso(); |
|
| 220 | + break; |
|
| 221 | + case $source instanceof EE_Venue: |
|
| 222 | + $country_iso = $source->country_ID(); |
|
| 223 | + break; |
|
| 224 | + default: |
|
| 225 | + $country_iso = null; |
|
| 226 | + break; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if ($country_iso) { |
|
| 230 | + return EEM_Country::instance()->get_one_by_ID($country_iso); |
|
| 231 | + } |
|
| 232 | + return null; |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param mixed $model The model instance. |
| 59 | 59 | * @param array $fields The fields registered for the type. |
| 60 | 60 | */ |
| 61 | - public function __construct($model, array $fields ) |
|
| 61 | + public function __construct($model, array $fields) |
|
| 62 | 62 | { |
| 63 | 63 | $this->model = $model; |
| 64 | 64 | $this->fields = $fields; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $field = $this->fields[$fieldName]; |
| 82 | 82 | |
| 83 | 83 | // check if the field should be resolved. |
| 84 | - if (!$field->shouldResolve()) { |
|
| 84 | + if ( ! $field->shouldResolve()) { |
|
| 85 | 85 | return null; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Check if the field has a key mapped to model. |
| 94 | - if (!empty($field->key())) { |
|
| 94 | + if ( ! empty($field->key())) { |
|
| 95 | 95 | $value = $source->{$field->key()}(); |
| 96 | 96 | return $field->mayBeFormatValue($value); |
| 97 | 97 | } |
@@ -20,19 +20,10 @@ |
||
| 20 | 20 | |
| 21 | 21 | namespace EventEspresso\core\services\graphql; |
| 22 | 22 | |
| 23 | -use EE_Enum_Text_Field; |
|
| 24 | -use EE_Model_Field_Base; |
|
| 25 | -use EE_Post_Content_Field; |
|
| 26 | -use EE_WP_User_Field; |
|
| 27 | 23 | use EEM_Base; |
| 28 | 24 | use EE_Base_Class; |
| 29 | - |
|
| 30 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
| 31 | -use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
| 32 | 25 | use EventEspresso\core\services\graphql\TypeBase; |
| 33 | 26 | use EventEspresso\core\domain\services\graphql\resolvers\FieldResolver; |
| 34 | - |
|
| 35 | -use WPGraphQL\Data\DataSource; |
|
| 36 | 27 | use WPGraphQL\Model\Post; |
| 37 | 28 | use GraphQL\Type\Definition\ResolveInfo; |
| 38 | 29 | use WPGraphQL\AppContext; |
@@ -48,218 +48,218 @@ |
||
| 48 | 48 | abstract class TypeBase implements TypeInterface |
| 49 | 49 | { |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var EEM_Base $model |
|
| 53 | - */ |
|
| 54 | - protected $model; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @var string $name |
|
| 58 | - */ |
|
| 59 | - protected $name = ''; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var string $description |
|
| 63 | - */ |
|
| 64 | - protected $description = ''; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @var array $fields |
|
| 68 | - */ |
|
| 69 | - protected $fields = []; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @var array $graphql_to_model_map |
|
| 73 | - */ |
|
| 74 | - protected $graphql_to_model_map = []; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @var FieldResolver $field_resolver |
|
| 78 | - */ |
|
| 79 | - protected $field_resolver; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @var bool $is_custom_post_type |
|
| 83 | - */ |
|
| 84 | - protected $is_custom_post_type = false; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * TypeBase constructor. |
|
| 88 | - * |
|
| 89 | - */ |
|
| 90 | - public function __construct() |
|
| 91 | - { |
|
| 92 | - $this->setFields($this->getFields()); |
|
| 93 | - |
|
| 94 | - $this->field_resolver = new FieldResolver( |
|
| 95 | - $this->model, |
|
| 96 | - $this->getFieldsForResolver() |
|
| 97 | - ); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * @return string |
|
| 103 | - */ |
|
| 104 | - public function name() |
|
| 105 | - { |
|
| 106 | - return $this->name; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @param string $name |
|
| 112 | - */ |
|
| 113 | - protected function setName($name) |
|
| 114 | - { |
|
| 115 | - $this->name = $name; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function description() |
|
| 123 | - { |
|
| 124 | - return $this->description; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @param string $description |
|
| 130 | - */ |
|
| 131 | - protected function setDescription($description) |
|
| 132 | - { |
|
| 133 | - $this->description = $description; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @return array |
|
| 139 | - * @since $VID:$ |
|
| 140 | - */ |
|
| 141 | - public function fields() |
|
| 142 | - { |
|
| 143 | - return (array) $this->fields; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @param array $fields |
|
| 149 | - */ |
|
| 150 | - protected function setFields(array $fields) |
|
| 151 | - { |
|
| 152 | - $this->fields = $fields; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @return array |
|
| 157 | - * @since $VID:$ |
|
| 158 | - */ |
|
| 159 | - public function getFields() |
|
| 160 | - { |
|
| 161 | - return []; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Creates a key map to pass to GrapQL registration. |
|
| 167 | - * @return array |
|
| 168 | - * @since $VID:$ |
|
| 169 | - */ |
|
| 170 | - public function getFieldsForGQL() |
|
| 171 | - { |
|
| 172 | - $fields = []; |
|
| 173 | - foreach ($this->fields() as $field) { |
|
| 174 | - $config = $field->toArray(); |
|
| 175 | - $config['resolve'] = [$this, 'resolveField']; |
|
| 176 | - $fields[$field->name()] = $config; |
|
| 177 | - } |
|
| 178 | - return $fields; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Creates a key map for internal resolver. |
|
| 184 | - * @return array |
|
| 185 | - * @since $VID:$ |
|
| 186 | - */ |
|
| 187 | - public function getFieldsForResolver() |
|
| 188 | - { |
|
| 189 | - $fields = []; |
|
| 190 | - foreach ($this->fields() as $field) { |
|
| 191 | - $fields[$field->name()] = $field; |
|
| 192 | - } |
|
| 193 | - return $fields; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @return bool |
|
| 199 | - */ |
|
| 200 | - public function isCustomPostType() |
|
| 201 | - { |
|
| 202 | - return $this->is_custom_post_type; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @param bool $is_custom_post_type |
|
| 208 | - */ |
|
| 209 | - protected function setIsCustomPostType($is_custom_post_type) |
|
| 210 | - { |
|
| 211 | - $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @param int $value |
|
| 217 | - * @return int |
|
| 218 | - * @since $VID:$ |
|
| 219 | - */ |
|
| 220 | - public function parseInfiniteValue($value) |
|
| 221 | - { |
|
| 222 | - return $value === EE_INF || is_infinite($value) ? -1 : $value; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * @param mixed $source |
|
| 228 | - * @return EE_Base_Class|null |
|
| 229 | - * @since $VID:$ |
|
| 230 | - */ |
|
| 231 | - private function getModel($source) |
|
| 232 | - { |
|
| 233 | - // If it comes from a custom connection |
|
| 234 | - // where the $source is already instantiated. |
|
| 235 | - if (is_subclass_of($source, 'EE_Base_Class')) { |
|
| 236 | - return $source; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $id = $source instanceof Post ? $source->ID : 0; |
|
| 240 | - |
|
| 241 | - if ($id) { |
|
| 242 | - return $this->model->get_one_by_ID($id); |
|
| 243 | - } |
|
| 244 | - return null; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
| 249 | - * @param array $args The inputArgs on the field |
|
| 250 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 251 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 252 | - * @return string |
|
| 253 | - * @since $VID:$ |
|
| 254 | - */ |
|
| 255 | - public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
| 256 | - { |
|
| 257 | - $source = $this->getModel($source); |
|
| 258 | - if (is_subclass_of($source, 'EE_Base_Class')) { |
|
| 259 | - |
|
| 260 | - return $this->field_resolver->resolve($source, $args, $context, $info); |
|
| 261 | - } |
|
| 262 | - return null; |
|
| 263 | - } |
|
| 51 | + /** |
|
| 52 | + * @var EEM_Base $model |
|
| 53 | + */ |
|
| 54 | + protected $model; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @var string $name |
|
| 58 | + */ |
|
| 59 | + protected $name = ''; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var string $description |
|
| 63 | + */ |
|
| 64 | + protected $description = ''; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @var array $fields |
|
| 68 | + */ |
|
| 69 | + protected $fields = []; |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @var array $graphql_to_model_map |
|
| 73 | + */ |
|
| 74 | + protected $graphql_to_model_map = []; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @var FieldResolver $field_resolver |
|
| 78 | + */ |
|
| 79 | + protected $field_resolver; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @var bool $is_custom_post_type |
|
| 83 | + */ |
|
| 84 | + protected $is_custom_post_type = false; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * TypeBase constructor. |
|
| 88 | + * |
|
| 89 | + */ |
|
| 90 | + public function __construct() |
|
| 91 | + { |
|
| 92 | + $this->setFields($this->getFields()); |
|
| 93 | + |
|
| 94 | + $this->field_resolver = new FieldResolver( |
|
| 95 | + $this->model, |
|
| 96 | + $this->getFieldsForResolver() |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * @return string |
|
| 103 | + */ |
|
| 104 | + public function name() |
|
| 105 | + { |
|
| 106 | + return $this->name; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @param string $name |
|
| 112 | + */ |
|
| 113 | + protected function setName($name) |
|
| 114 | + { |
|
| 115 | + $this->name = $name; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function description() |
|
| 123 | + { |
|
| 124 | + return $this->description; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @param string $description |
|
| 130 | + */ |
|
| 131 | + protected function setDescription($description) |
|
| 132 | + { |
|
| 133 | + $this->description = $description; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @return array |
|
| 139 | + * @since $VID:$ |
|
| 140 | + */ |
|
| 141 | + public function fields() |
|
| 142 | + { |
|
| 143 | + return (array) $this->fields; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @param array $fields |
|
| 149 | + */ |
|
| 150 | + protected function setFields(array $fields) |
|
| 151 | + { |
|
| 152 | + $this->fields = $fields; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @return array |
|
| 157 | + * @since $VID:$ |
|
| 158 | + */ |
|
| 159 | + public function getFields() |
|
| 160 | + { |
|
| 161 | + return []; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Creates a key map to pass to GrapQL registration. |
|
| 167 | + * @return array |
|
| 168 | + * @since $VID:$ |
|
| 169 | + */ |
|
| 170 | + public function getFieldsForGQL() |
|
| 171 | + { |
|
| 172 | + $fields = []; |
|
| 173 | + foreach ($this->fields() as $field) { |
|
| 174 | + $config = $field->toArray(); |
|
| 175 | + $config['resolve'] = [$this, 'resolveField']; |
|
| 176 | + $fields[$field->name()] = $config; |
|
| 177 | + } |
|
| 178 | + return $fields; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Creates a key map for internal resolver. |
|
| 184 | + * @return array |
|
| 185 | + * @since $VID:$ |
|
| 186 | + */ |
|
| 187 | + public function getFieldsForResolver() |
|
| 188 | + { |
|
| 189 | + $fields = []; |
|
| 190 | + foreach ($this->fields() as $field) { |
|
| 191 | + $fields[$field->name()] = $field; |
|
| 192 | + } |
|
| 193 | + return $fields; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @return bool |
|
| 199 | + */ |
|
| 200 | + public function isCustomPostType() |
|
| 201 | + { |
|
| 202 | + return $this->is_custom_post_type; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param bool $is_custom_post_type |
|
| 208 | + */ |
|
| 209 | + protected function setIsCustomPostType($is_custom_post_type) |
|
| 210 | + { |
|
| 211 | + $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @param int $value |
|
| 217 | + * @return int |
|
| 218 | + * @since $VID:$ |
|
| 219 | + */ |
|
| 220 | + public function parseInfiniteValue($value) |
|
| 221 | + { |
|
| 222 | + return $value === EE_INF || is_infinite($value) ? -1 : $value; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * @param mixed $source |
|
| 228 | + * @return EE_Base_Class|null |
|
| 229 | + * @since $VID:$ |
|
| 230 | + */ |
|
| 231 | + private function getModel($source) |
|
| 232 | + { |
|
| 233 | + // If it comes from a custom connection |
|
| 234 | + // where the $source is already instantiated. |
|
| 235 | + if (is_subclass_of($source, 'EE_Base_Class')) { |
|
| 236 | + return $source; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $id = $source instanceof Post ? $source->ID : 0; |
|
| 240 | + |
|
| 241 | + if ($id) { |
|
| 242 | + return $this->model->get_one_by_ID($id); |
|
| 243 | + } |
|
| 244 | + return null; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
| 249 | + * @param array $args The inputArgs on the field |
|
| 250 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 251 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 252 | + * @return string |
|
| 253 | + * @since $VID:$ |
|
| 254 | + */ |
|
| 255 | + public function resolveField($source, $args, AppContext $context, ResolveInfo $info) |
|
| 256 | + { |
|
| 257 | + $source = $this->getModel($source); |
|
| 258 | + if (is_subclass_of($source, 'EE_Base_Class')) { |
|
| 259 | + |
|
| 260 | + return $this->field_resolver->resolve($source, $args, $context, $info); |
|
| 261 | + } |
|
| 262 | + return null; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | \ No newline at end of file |
@@ -34,54 +34,54 @@ |
||
| 34 | 34 | class TypesManager |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var TypeCollection|TypeInterface[] $types |
|
| 39 | - */ |
|
| 40 | - private $types; |
|
| 37 | + /** |
|
| 38 | + * @var TypeCollection|TypeInterface[] $types |
|
| 39 | + */ |
|
| 40 | + private $types; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * TypesManager constructor. |
|
| 45 | - * |
|
| 46 | - * @param TypeCollection|TypeInterface[] $types |
|
| 47 | - */ |
|
| 48 | - public function __construct(TypeCollection $types) |
|
| 49 | - { |
|
| 50 | - $this->types = $types; |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * TypesManager constructor. |
|
| 45 | + * |
|
| 46 | + * @param TypeCollection|TypeInterface[] $types |
|
| 47 | + */ |
|
| 48 | + public function __construct(TypeCollection $types) |
|
| 49 | + { |
|
| 50 | + $this->types = $types; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 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, 'registerTypes'], 10); |
|
| 63 | - } |
|
| 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, 'registerTypes'], 10); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - public function registerTypes() |
|
| 67 | - { |
|
| 68 | - // loop through the collection of types and register their fields |
|
| 69 | - foreach ($this->types as $type) { |
|
| 70 | - $fields = $type->getFieldsForGQL(); |
|
| 71 | - /** @var TypeInterface $type */ |
|
| 72 | - if ($type->isCustomPostType()) { |
|
| 73 | - foreach ($fields as $field => $config) { |
|
| 74 | - register_graphql_field($type->name(), $field, $config); |
|
| 75 | - } |
|
| 76 | - } else { |
|
| 77 | - register_graphql_object_type( |
|
| 78 | - $type->name(), |
|
| 79 | - [ |
|
| 80 | - 'description' => $type->description(), |
|
| 81 | - 'fields' => $fields, |
|
| 82 | - ] |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } |
|
| 66 | + public function registerTypes() |
|
| 67 | + { |
|
| 68 | + // loop through the collection of types and register their fields |
|
| 69 | + foreach ($this->types as $type) { |
|
| 70 | + $fields = $type->getFieldsForGQL(); |
|
| 71 | + /** @var TypeInterface $type */ |
|
| 72 | + if ($type->isCustomPostType()) { |
|
| 73 | + foreach ($fields as $field => $config) { |
|
| 74 | + register_graphql_field($type->name(), $field, $config); |
|
| 75 | + } |
|
| 76 | + } else { |
|
| 77 | + register_graphql_object_type( |
|
| 78 | + $type->name(), |
|
| 79 | + [ |
|
| 80 | + 'description' => $type->description(), |
|
| 81 | + 'fields' => $fields, |
|
| 82 | + ] |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | } |
| 88 | 88 | \ No newline at end of file |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | interface ResolverInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param $source |
|
| 21 | - * @param array $args |
|
| 22 | - * @param AppContext $context |
|
| 23 | - * @param ResolveInfo $info |
|
| 24 | - * @return mixed |
|
| 25 | - * @since $VID:$ |
|
| 26 | - */ |
|
| 27 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
| 19 | + /** |
|
| 20 | + * @param $source |
|
| 21 | + * @param array $args |
|
| 22 | + * @param AppContext $context |
|
| 23 | + * @param ResolveInfo $info |
|
| 24 | + * @return mixed |
|
| 25 | + * @since $VID:$ |
|
| 26 | + */ |
|
| 27 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -35,197 +35,197 @@ |
||
| 35 | 35 | class Datetime extends TypeBase |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * EventDate constructor. |
|
| 40 | - * |
|
| 41 | - * @param EEM_Datetime $datetime_model |
|
| 42 | - */ |
|
| 43 | - public function __construct(EEM_Datetime $datetime_model) |
|
| 44 | - { |
|
| 45 | - $this->model = $datetime_model; |
|
| 46 | - $this->setName('Datetime'); |
|
| 47 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
| 48 | - $this->setIsCustomPostType(false); |
|
| 38 | + /** |
|
| 39 | + * EventDate constructor. |
|
| 40 | + * |
|
| 41 | + * @param EEM_Datetime $datetime_model |
|
| 42 | + */ |
|
| 43 | + public function __construct(EEM_Datetime $datetime_model) |
|
| 44 | + { |
|
| 45 | + $this->model = $datetime_model; |
|
| 46 | + $this->setName('Datetime'); |
|
| 47 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
| 48 | + $this->setIsCustomPostType(false); |
|
| 49 | 49 | |
| 50 | - parent::__construct(); |
|
| 51 | - } |
|
| 50 | + parent::__construct(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return array |
|
| 55 | - * @since $VID:$ |
|
| 56 | - */ |
|
| 57 | - public function getFields() |
|
| 58 | - { |
|
| 59 | - return [ |
|
| 60 | - new GraphQLField( |
|
| 61 | - 'id', |
|
| 62 | - [ |
|
| 63 | - 'key' => 'ID', |
|
| 64 | - 'type' => [ |
|
| 65 | - 'non_null' => 'Int', |
|
| 66 | - ], |
|
| 67 | - 'description' => __('The datetime ID.', 'event_espresso'), |
|
| 68 | - ] |
|
| 69 | - ), |
|
| 70 | - new GraphQLField( |
|
| 71 | - 'name', |
|
| 72 | - [ |
|
| 73 | - 'key' => 'name', |
|
| 74 | - 'type' => 'String', |
|
| 75 | - 'description' => __('Datetime Name', 'event_espresso'), |
|
| 76 | - ] |
|
| 77 | - ), |
|
| 78 | - new GraphQLField( |
|
| 79 | - 'description', |
|
| 80 | - [ |
|
| 81 | - 'key' => 'description', |
|
| 82 | - 'type' => 'String', |
|
| 83 | - 'description' => __('Description for Datetime', 'event_espresso'), |
|
| 84 | - ] |
|
| 85 | - ), |
|
| 86 | - new GraphQLField( |
|
| 87 | - 'start', |
|
| 88 | - [ |
|
| 89 | - 'key' => 'start', |
|
| 90 | - 'type' => 'String', |
|
| 91 | - 'description' => __('Start timestamp of Event', 'event_espresso'), |
|
| 92 | - ] |
|
| 93 | - ), |
|
| 94 | - new GraphQLField( |
|
| 95 | - 'startDate', |
|
| 96 | - [ |
|
| 97 | - 'key' => 'start_date', |
|
| 98 | - 'type' => 'String', |
|
| 99 | - 'description' => __('Start time/date of Event', 'event_espresso'), |
|
| 100 | - ] |
|
| 101 | - ), |
|
| 102 | - new GraphQLField( |
|
| 103 | - 'end', |
|
| 104 | - [ |
|
| 105 | - 'key' => 'end', |
|
| 106 | - 'type' => 'String', |
|
| 107 | - 'description' => __('End timestamp of Event', 'event_espresso'), |
|
| 108 | - ] |
|
| 109 | - ), |
|
| 110 | - new GraphQLField( |
|
| 111 | - 'endDate', |
|
| 112 | - [ |
|
| 113 | - 'key' => 'end_date', |
|
| 114 | - 'type' => 'String', |
|
| 115 | - 'description' => __('End time/date of Event', 'event_espresso'), |
|
| 116 | - ] |
|
| 117 | - ), |
|
| 118 | - new GraphQLField( |
|
| 119 | - 'startTime', |
|
| 120 | - [ |
|
| 121 | - 'key' => 'start_time', |
|
| 122 | - 'type' => 'String', |
|
| 123 | - 'description' => __('Start time of Event', 'event_espresso'), |
|
| 124 | - ] |
|
| 125 | - ), |
|
| 126 | - new GraphQLField( |
|
| 127 | - 'endTime', |
|
| 128 | - [ |
|
| 129 | - 'key' => 'end_time', |
|
| 130 | - 'type' => 'String', |
|
| 131 | - 'description' => __('End time of Event', 'event_espresso'), |
|
| 132 | - ] |
|
| 133 | - ), |
|
| 134 | - new GraphQLField( |
|
| 135 | - 'capacity', |
|
| 136 | - [ |
|
| 137 | - 'key' => 'reg_limit', |
|
| 138 | - 'type' => 'Int', |
|
| 139 | - 'description' => __('Registration Limit for this time', 'event_espresso'), |
|
| 140 | - 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 141 | - ] |
|
| 142 | - ), |
|
| 143 | - new GraphQLField( |
|
| 144 | - 'sold', |
|
| 145 | - [ |
|
| 146 | - 'key' => 'sold', |
|
| 147 | - 'type' => 'Int', |
|
| 148 | - 'description' => __('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
| 149 | - ] |
|
| 150 | - ), |
|
| 151 | - new GraphQLField( |
|
| 152 | - 'reserved', |
|
| 153 | - [ |
|
| 154 | - 'key' => 'reserved', |
|
| 155 | - 'type' => 'Int', |
|
| 156 | - 'description' => __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
| 157 | - ] |
|
| 158 | - ), |
|
| 159 | - new GraphQLField( |
|
| 160 | - 'order', |
|
| 161 | - [ |
|
| 162 | - 'key' => 'order', |
|
| 163 | - 'type' => 'Int', |
|
| 164 | - 'description' => __('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 165 | - ] |
|
| 166 | - ), |
|
| 167 | - new GraphQLField( |
|
| 168 | - 'length', |
|
| 169 | - [ |
|
| 170 | - 'key' => 'length', |
|
| 171 | - 'type' => 'Int', |
|
| 172 | - 'description' => __('The length of the event (start to end time) in seconds', 'event_espresso'), |
|
| 173 | - ] |
|
| 174 | - ), |
|
| 175 | - new GraphQLField( |
|
| 176 | - 'parent', |
|
| 177 | - [ |
|
| 178 | - 'type' => 'Datetime', |
|
| 179 | - 'description' => __('The parent datetime of the current datetime', 'event_espresso'), |
|
| 180 | - ] |
|
| 181 | - ), |
|
| 182 | - new GraphQLField( |
|
| 183 | - 'isPrimary', |
|
| 184 | - [ |
|
| 185 | - 'key' => 'is_primary', |
|
| 186 | - 'type' => 'Boolean', |
|
| 187 | - 'description' => __('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 188 | - ] |
|
| 189 | - ), |
|
| 190 | - new GraphQLField( |
|
| 191 | - 'isSoldOut', |
|
| 192 | - [ |
|
| 193 | - 'key' => 'sold_out', |
|
| 194 | - 'type' => 'Boolean', |
|
| 195 | - 'description' => __('Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', 'event_espresso'), |
|
| 196 | - ] |
|
| 197 | - ), |
|
| 198 | - new GraphQLField( |
|
| 199 | - 'isUpcoming', |
|
| 200 | - [ |
|
| 201 | - 'key' => 'is_upcoming', |
|
| 202 | - 'type' => 'Boolean', |
|
| 203 | - 'description' => __('Whether the date is upcoming', 'event_espresso'), |
|
| 204 | - ] |
|
| 205 | - ), |
|
| 206 | - new GraphQLField( |
|
| 207 | - 'isActive', |
|
| 208 | - [ |
|
| 209 | - 'key' => 'is_active', |
|
| 210 | - 'type' => 'Boolean', |
|
| 211 | - 'description' => __('Flag indicating datetime is active', 'event_espresso'), |
|
| 212 | - ] |
|
| 213 | - ), |
|
| 214 | - new GraphQLField( |
|
| 215 | - 'isExpired', |
|
| 216 | - [ |
|
| 217 | - 'key' => 'is_expired', |
|
| 218 | - 'type' => 'Boolean', |
|
| 219 | - 'description' => __('Flag indicating datetime is expired or not', 'event_espresso'), |
|
| 220 | - ] |
|
| 221 | - ), |
|
| 222 | - new GraphQLField( |
|
| 223 | - 'event', |
|
| 224 | - [ |
|
| 225 | - 'type' => 'Event', |
|
| 226 | - 'description' => __('Event of the datetime.', 'event_espresso'), |
|
| 227 | - ] |
|
| 228 | - ), |
|
| 229 | - ]; |
|
| 230 | - } |
|
| 53 | + /** |
|
| 54 | + * @return array |
|
| 55 | + * @since $VID:$ |
|
| 56 | + */ |
|
| 57 | + public function getFields() |
|
| 58 | + { |
|
| 59 | + return [ |
|
| 60 | + new GraphQLField( |
|
| 61 | + 'id', |
|
| 62 | + [ |
|
| 63 | + 'key' => 'ID', |
|
| 64 | + 'type' => [ |
|
| 65 | + 'non_null' => 'Int', |
|
| 66 | + ], |
|
| 67 | + 'description' => __('The datetime ID.', 'event_espresso'), |
|
| 68 | + ] |
|
| 69 | + ), |
|
| 70 | + new GraphQLField( |
|
| 71 | + 'name', |
|
| 72 | + [ |
|
| 73 | + 'key' => 'name', |
|
| 74 | + 'type' => 'String', |
|
| 75 | + 'description' => __('Datetime Name', 'event_espresso'), |
|
| 76 | + ] |
|
| 77 | + ), |
|
| 78 | + new GraphQLField( |
|
| 79 | + 'description', |
|
| 80 | + [ |
|
| 81 | + 'key' => 'description', |
|
| 82 | + 'type' => 'String', |
|
| 83 | + 'description' => __('Description for Datetime', 'event_espresso'), |
|
| 84 | + ] |
|
| 85 | + ), |
|
| 86 | + new GraphQLField( |
|
| 87 | + 'start', |
|
| 88 | + [ |
|
| 89 | + 'key' => 'start', |
|
| 90 | + 'type' => 'String', |
|
| 91 | + 'description' => __('Start timestamp of Event', 'event_espresso'), |
|
| 92 | + ] |
|
| 93 | + ), |
|
| 94 | + new GraphQLField( |
|
| 95 | + 'startDate', |
|
| 96 | + [ |
|
| 97 | + 'key' => 'start_date', |
|
| 98 | + 'type' => 'String', |
|
| 99 | + 'description' => __('Start time/date of Event', 'event_espresso'), |
|
| 100 | + ] |
|
| 101 | + ), |
|
| 102 | + new GraphQLField( |
|
| 103 | + 'end', |
|
| 104 | + [ |
|
| 105 | + 'key' => 'end', |
|
| 106 | + 'type' => 'String', |
|
| 107 | + 'description' => __('End timestamp of Event', 'event_espresso'), |
|
| 108 | + ] |
|
| 109 | + ), |
|
| 110 | + new GraphQLField( |
|
| 111 | + 'endDate', |
|
| 112 | + [ |
|
| 113 | + 'key' => 'end_date', |
|
| 114 | + 'type' => 'String', |
|
| 115 | + 'description' => __('End time/date of Event', 'event_espresso'), |
|
| 116 | + ] |
|
| 117 | + ), |
|
| 118 | + new GraphQLField( |
|
| 119 | + 'startTime', |
|
| 120 | + [ |
|
| 121 | + 'key' => 'start_time', |
|
| 122 | + 'type' => 'String', |
|
| 123 | + 'description' => __('Start time of Event', 'event_espresso'), |
|
| 124 | + ] |
|
| 125 | + ), |
|
| 126 | + new GraphQLField( |
|
| 127 | + 'endTime', |
|
| 128 | + [ |
|
| 129 | + 'key' => 'end_time', |
|
| 130 | + 'type' => 'String', |
|
| 131 | + 'description' => __('End time of Event', 'event_espresso'), |
|
| 132 | + ] |
|
| 133 | + ), |
|
| 134 | + new GraphQLField( |
|
| 135 | + 'capacity', |
|
| 136 | + [ |
|
| 137 | + 'key' => 'reg_limit', |
|
| 138 | + 'type' => 'Int', |
|
| 139 | + 'description' => __('Registration Limit for this time', 'event_espresso'), |
|
| 140 | + 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 141 | + ] |
|
| 142 | + ), |
|
| 143 | + new GraphQLField( |
|
| 144 | + 'sold', |
|
| 145 | + [ |
|
| 146 | + 'key' => 'sold', |
|
| 147 | + 'type' => 'Int', |
|
| 148 | + 'description' => __('How many sales for this Datetime that have occurred', 'event_espresso'), |
|
| 149 | + ] |
|
| 150 | + ), |
|
| 151 | + new GraphQLField( |
|
| 152 | + 'reserved', |
|
| 153 | + [ |
|
| 154 | + 'key' => 'reserved', |
|
| 155 | + 'type' => 'Int', |
|
| 156 | + 'description' => __('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'), |
|
| 157 | + ] |
|
| 158 | + ), |
|
| 159 | + new GraphQLField( |
|
| 160 | + 'order', |
|
| 161 | + [ |
|
| 162 | + 'key' => 'order', |
|
| 163 | + 'type' => 'Int', |
|
| 164 | + 'description' => __('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 165 | + ] |
|
| 166 | + ), |
|
| 167 | + new GraphQLField( |
|
| 168 | + 'length', |
|
| 169 | + [ |
|
| 170 | + 'key' => 'length', |
|
| 171 | + 'type' => 'Int', |
|
| 172 | + 'description' => __('The length of the event (start to end time) in seconds', 'event_espresso'), |
|
| 173 | + ] |
|
| 174 | + ), |
|
| 175 | + new GraphQLField( |
|
| 176 | + 'parent', |
|
| 177 | + [ |
|
| 178 | + 'type' => 'Datetime', |
|
| 179 | + 'description' => __('The parent datetime of the current datetime', 'event_espresso'), |
|
| 180 | + ] |
|
| 181 | + ), |
|
| 182 | + new GraphQLField( |
|
| 183 | + 'isPrimary', |
|
| 184 | + [ |
|
| 185 | + 'key' => 'is_primary', |
|
| 186 | + 'type' => 'Boolean', |
|
| 187 | + 'description' => __('Flag indicating datetime is primary one for event', 'event_espresso'), |
|
| 188 | + ] |
|
| 189 | + ), |
|
| 190 | + new GraphQLField( |
|
| 191 | + 'isSoldOut', |
|
| 192 | + [ |
|
| 193 | + 'key' => 'sold_out', |
|
| 194 | + 'type' => 'Boolean', |
|
| 195 | + 'description' => __('Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', 'event_espresso'), |
|
| 196 | + ] |
|
| 197 | + ), |
|
| 198 | + new GraphQLField( |
|
| 199 | + 'isUpcoming', |
|
| 200 | + [ |
|
| 201 | + 'key' => 'is_upcoming', |
|
| 202 | + 'type' => 'Boolean', |
|
| 203 | + 'description' => __('Whether the date is upcoming', 'event_espresso'), |
|
| 204 | + ] |
|
| 205 | + ), |
|
| 206 | + new GraphQLField( |
|
| 207 | + 'isActive', |
|
| 208 | + [ |
|
| 209 | + 'key' => 'is_active', |
|
| 210 | + 'type' => 'Boolean', |
|
| 211 | + 'description' => __('Flag indicating datetime is active', 'event_espresso'), |
|
| 212 | + ] |
|
| 213 | + ), |
|
| 214 | + new GraphQLField( |
|
| 215 | + 'isExpired', |
|
| 216 | + [ |
|
| 217 | + 'key' => 'is_expired', |
|
| 218 | + 'type' => 'Boolean', |
|
| 219 | + 'description' => __('Flag indicating datetime is expired or not', 'event_espresso'), |
|
| 220 | + ] |
|
| 221 | + ), |
|
| 222 | + new GraphQLField( |
|
| 223 | + 'event', |
|
| 224 | + [ |
|
| 225 | + 'type' => 'Event', |
|
| 226 | + 'description' => __('Event of the datetime.', 'event_espresso'), |
|
| 227 | + ] |
|
| 228 | + ), |
|
| 229 | + ]; |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | \ No newline at end of file |
@@ -35,70 +35,70 @@ |
||
| 35 | 35 | class State extends TypeBase |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * State constructor. |
|
| 40 | - * |
|
| 41 | - * @param EEM_State $state_model |
|
| 42 | - */ |
|
| 43 | - public function __construct(EEM_State $state_model) |
|
| 44 | - { |
|
| 45 | - $this->model = $state_model; |
|
| 46 | - $this->setName('State'); |
|
| 47 | - $this->setDescription(__('A state', 'event_espresso')); |
|
| 48 | - $this->setIsCustomPostType(false); |
|
| 38 | + /** |
|
| 39 | + * State constructor. |
|
| 40 | + * |
|
| 41 | + * @param EEM_State $state_model |
|
| 42 | + */ |
|
| 43 | + public function __construct(EEM_State $state_model) |
|
| 44 | + { |
|
| 45 | + $this->model = $state_model; |
|
| 46 | + $this->setName('State'); |
|
| 47 | + $this->setDescription(__('A state', 'event_espresso')); |
|
| 48 | + $this->setIsCustomPostType(false); |
|
| 49 | 49 | |
| 50 | - parent::__construct(); |
|
| 51 | - } |
|
| 50 | + parent::__construct(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - * @since $VID:$ |
|
| 57 | - */ |
|
| 58 | - public function getFields() |
|
| 59 | - { |
|
| 60 | - return [ |
|
| 61 | - new GraphQLField( |
|
| 62 | - 'id', |
|
| 63 | - [ |
|
| 64 | - 'key' => 'ID', |
|
| 65 | - 'type' => [ |
|
| 66 | - 'non_null' => 'Int', |
|
| 67 | - ], |
|
| 68 | - 'description' => __( 'State ID', 'event_espresso' ), |
|
| 69 | - ] |
|
| 70 | - ), |
|
| 71 | - new GraphQLField( |
|
| 72 | - 'abbreviation', |
|
| 73 | - [ |
|
| 74 | - 'key' => 'abbrev', |
|
| 75 | - 'type' => 'String', |
|
| 76 | - 'description' => __( 'State Abbreviation', 'event_espresso' ), |
|
| 77 | - ] |
|
| 78 | - ), |
|
| 79 | - new GraphQLField( |
|
| 80 | - 'name', |
|
| 81 | - [ |
|
| 82 | - 'key' => 'name', |
|
| 83 | - 'type' => 'String', |
|
| 84 | - 'description' => __('State Name', 'event_espresso'), |
|
| 85 | - ] |
|
| 86 | - ), |
|
| 87 | - new GraphQLField( |
|
| 88 | - 'isActive', |
|
| 89 | - [ |
|
| 90 | - 'key' => 'active', |
|
| 91 | - 'type' => 'Boolean', |
|
| 92 | - 'description' => __('State Active Flag', 'event_espresso'), |
|
| 93 | - ] |
|
| 94 | - ), |
|
| 95 | - new GraphQLField( |
|
| 96 | - 'country', |
|
| 97 | - [ |
|
| 98 | - 'type' => 'Country', |
|
| 99 | - 'description' => __('Country for the state', 'event_espresso'), |
|
| 100 | - ] |
|
| 101 | - ), |
|
| 102 | - ]; |
|
| 103 | - } |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + * @since $VID:$ |
|
| 57 | + */ |
|
| 58 | + public function getFields() |
|
| 59 | + { |
|
| 60 | + return [ |
|
| 61 | + new GraphQLField( |
|
| 62 | + 'id', |
|
| 63 | + [ |
|
| 64 | + 'key' => 'ID', |
|
| 65 | + 'type' => [ |
|
| 66 | + 'non_null' => 'Int', |
|
| 67 | + ], |
|
| 68 | + 'description' => __( 'State ID', 'event_espresso' ), |
|
| 69 | + ] |
|
| 70 | + ), |
|
| 71 | + new GraphQLField( |
|
| 72 | + 'abbreviation', |
|
| 73 | + [ |
|
| 74 | + 'key' => 'abbrev', |
|
| 75 | + 'type' => 'String', |
|
| 76 | + 'description' => __( 'State Abbreviation', 'event_espresso' ), |
|
| 77 | + ] |
|
| 78 | + ), |
|
| 79 | + new GraphQLField( |
|
| 80 | + 'name', |
|
| 81 | + [ |
|
| 82 | + 'key' => 'name', |
|
| 83 | + 'type' => 'String', |
|
| 84 | + 'description' => __('State Name', 'event_espresso'), |
|
| 85 | + ] |
|
| 86 | + ), |
|
| 87 | + new GraphQLField( |
|
| 88 | + 'isActive', |
|
| 89 | + [ |
|
| 90 | + 'key' => 'active', |
|
| 91 | + 'type' => 'Boolean', |
|
| 92 | + 'description' => __('State Active Flag', 'event_espresso'), |
|
| 93 | + ] |
|
| 94 | + ), |
|
| 95 | + new GraphQLField( |
|
| 96 | + 'country', |
|
| 97 | + [ |
|
| 98 | + 'type' => 'Country', |
|
| 99 | + 'description' => __('Country for the state', 'event_espresso'), |
|
| 100 | + ] |
|
| 101 | + ), |
|
| 102 | + ]; |
|
| 103 | + } |
|
| 104 | 104 | } |
| 105 | 105 | \ No newline at end of file |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'type' => [ |
| 66 | 66 | 'non_null' => 'Int', |
| 67 | 67 | ], |
| 68 | - 'description' => __( 'State ID', 'event_espresso' ), |
|
| 68 | + 'description' => __('State ID', 'event_espresso'), |
|
| 69 | 69 | ] |
| 70 | 70 | ), |
| 71 | 71 | new GraphQLField( |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | [ |
| 74 | 74 | 'key' => 'abbrev', |
| 75 | 75 | 'type' => 'String', |
| 76 | - 'description' => __( 'State Abbreviation', 'event_espresso' ), |
|
| 76 | + 'description' => __('State Abbreviation', 'event_espresso'), |
|
| 77 | 77 | ] |
| 78 | 78 | ), |
| 79 | 79 | new GraphQLField( |
@@ -35,208 +35,208 @@ |
||
| 35 | 35 | class Ticket extends TypeBase |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Ticket constructor. |
|
| 40 | - * |
|
| 41 | - * @param EEM_Ticket $ticket_model |
|
| 42 | - */ |
|
| 43 | - public function __construct(EEM_Ticket $ticket_model) |
|
| 44 | - { |
|
| 45 | - $this->model = $ticket_model; |
|
| 46 | - $this->setName('Ticket'); |
|
| 47 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 48 | - $this->setIsCustomPostType(false); |
|
| 38 | + /** |
|
| 39 | + * Ticket constructor. |
|
| 40 | + * |
|
| 41 | + * @param EEM_Ticket $ticket_model |
|
| 42 | + */ |
|
| 43 | + public function __construct(EEM_Ticket $ticket_model) |
|
| 44 | + { |
|
| 45 | + $this->model = $ticket_model; |
|
| 46 | + $this->setName('Ticket'); |
|
| 47 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 48 | + $this->setIsCustomPostType(false); |
|
| 49 | 49 | |
| 50 | - parent::__construct(); |
|
| 51 | - } |
|
| 50 | + parent::__construct(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - * @since $VID:$ |
|
| 57 | - */ |
|
| 58 | - public function getFields() |
|
| 59 | - { |
|
| 60 | - return [ |
|
| 61 | - new GraphQLField( |
|
| 62 | - 'id', |
|
| 63 | - [ |
|
| 64 | - 'key' => 'ID', |
|
| 65 | - 'type' => [ |
|
| 66 | - 'non_null' => 'Int', |
|
| 67 | - ], |
|
| 68 | - 'description' => __('Ticket ID', 'event_espresso'), |
|
| 69 | - ] |
|
| 70 | - ), |
|
| 71 | - new GraphQLField( |
|
| 72 | - 'name', |
|
| 73 | - [ |
|
| 74 | - 'key' => 'name', |
|
| 75 | - 'type' => 'String', |
|
| 76 | - 'description' => __('Ticket Name', 'event_espresso'), |
|
| 77 | - ] |
|
| 78 | - ), |
|
| 79 | - new GraphQLField( |
|
| 80 | - 'description', |
|
| 81 | - [ |
|
| 82 | - 'key' => 'description', |
|
| 83 | - 'type' => 'String', |
|
| 84 | - 'description' => __('Description of Ticket', 'event_espresso'), |
|
| 85 | - ] |
|
| 86 | - ), |
|
| 87 | - new GraphQLField( |
|
| 88 | - 'startDate', |
|
| 89 | - [ |
|
| 90 | - 'key' => 'start_date', |
|
| 91 | - 'type' => 'String', |
|
| 92 | - 'description' => __('Start time/date of Ticket', 'event_espresso'), |
|
| 93 | - ] |
|
| 94 | - ), |
|
| 95 | - new GraphQLField( |
|
| 96 | - 'endDate', |
|
| 97 | - [ |
|
| 98 | - 'key' => 'end_date', |
|
| 99 | - 'type' => 'String', |
|
| 100 | - 'description' => __('End time/date of Ticket', 'event_espresso'), |
|
| 101 | - ] |
|
| 102 | - ), |
|
| 103 | - new GraphQLField( |
|
| 104 | - 'min', |
|
| 105 | - [ |
|
| 106 | - 'key' => 'min', |
|
| 107 | - 'type' => 'Int', |
|
| 108 | - 'description' => __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
| 109 | - ] |
|
| 110 | - ), |
|
| 111 | - new GraphQLField( |
|
| 112 | - 'max', |
|
| 113 | - [ |
|
| 114 | - 'key' => 'max', |
|
| 115 | - 'type' => 'Int', |
|
| 116 | - 'description' => __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
| 117 | - 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 118 | - ] |
|
| 119 | - ), |
|
| 120 | - new GraphQLField( |
|
| 121 | - 'price', |
|
| 122 | - [ |
|
| 123 | - 'key' => 'price', |
|
| 124 | - 'type' => 'Float', |
|
| 125 | - 'description' => __('Final calculated price for ticket', 'event_espresso'), |
|
| 126 | - ] |
|
| 127 | - ), |
|
| 128 | - new GraphQLField( |
|
| 129 | - 'sold', |
|
| 130 | - [ |
|
| 131 | - 'key' => 'sold', |
|
| 132 | - 'type' => 'Int', |
|
| 133 | - 'description' => __('Number of this ticket sold', 'event_espresso'), |
|
| 134 | - ] |
|
| 135 | - ), |
|
| 136 | - new GraphQLField( |
|
| 137 | - 'quantity', |
|
| 138 | - [ |
|
| 139 | - 'key' => 'qty', |
|
| 140 | - 'type' => 'Int', |
|
| 141 | - 'description' => __('Quantity of this ticket that is available', 'event_espresso'), |
|
| 142 | - 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 143 | - ] |
|
| 144 | - ), |
|
| 145 | - new GraphQLField( |
|
| 146 | - 'reserved', |
|
| 147 | - [ |
|
| 148 | - 'key' => 'reserved', |
|
| 149 | - 'type' => 'Int', |
|
| 150 | - 'description' => __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso'), |
|
| 151 | - ] |
|
| 152 | - ), |
|
| 153 | - new GraphQLField( |
|
| 154 | - 'uses', |
|
| 155 | - [ |
|
| 156 | - 'key' => 'uses', |
|
| 157 | - 'type' => 'Int', |
|
| 158 | - 'description' => __('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 159 | - 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 160 | - ] |
|
| 161 | - ), |
|
| 162 | - new GraphQLField( |
|
| 163 | - 'isRequired', |
|
| 164 | - [ |
|
| 165 | - 'key' => 'required', |
|
| 166 | - 'type' => 'Boolean', |
|
| 167 | - 'description' => __('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso'), |
|
| 168 | - ] |
|
| 169 | - ), |
|
| 170 | - new GraphQLField( |
|
| 171 | - 'isTaxable', |
|
| 172 | - [ |
|
| 173 | - 'key' => 'taxable', |
|
| 174 | - 'type' => 'Boolean', |
|
| 175 | - 'description' => __('Flag indicating whether there is tax applied on this ticket', 'event_espresso'), |
|
| 176 | - ] |
|
| 177 | - ), |
|
| 178 | - new GraphQLField( |
|
| 179 | - 'isDefault', |
|
| 180 | - [ |
|
| 181 | - 'key' => 'is_default', |
|
| 182 | - 'type' => 'Boolean', |
|
| 183 | - 'description' => __('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
| 184 | - ] |
|
| 185 | - ), |
|
| 186 | - new GraphQLField( |
|
| 187 | - 'order', |
|
| 188 | - [ |
|
| 189 | - 'key' => 'order', |
|
| 190 | - 'type' => 'Int', |
|
| 191 | - 'description' => __('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 192 | - ] |
|
| 193 | - ), |
|
| 194 | - new GraphQLField( |
|
| 195 | - 'row', |
|
| 196 | - [ |
|
| 197 | - 'key' => 'row', |
|
| 198 | - 'type' => 'Int', |
|
| 199 | - 'description' => __('How tickets are displayed in the ui', 'event_espresso'), |
|
| 200 | - ] |
|
| 201 | - ), |
|
| 202 | - new GraphQLField( |
|
| 203 | - 'wpUser', |
|
| 204 | - [ |
|
| 205 | - 'type' => 'User', |
|
| 206 | - 'description' => __('Ticket Creator ID', 'event_espresso'), |
|
| 207 | - ] |
|
| 208 | - ), |
|
| 209 | - new GraphQLField( |
|
| 210 | - 'parent', |
|
| 211 | - [ |
|
| 212 | - 'key' => 'ID', |
|
| 213 | - 'type' => 'Ticket', |
|
| 214 | - 'description' => __('The parent ticket of the current ticket', 'event_espresso'), |
|
| 215 | - ] |
|
| 216 | - ), |
|
| 217 | - new GraphQLField( |
|
| 218 | - 'reverseCalculate', |
|
| 219 | - [ |
|
| 220 | - 'key' => 'reverse_calculate', |
|
| 221 | - 'type' => 'Boolean', |
|
| 222 | - 'description' => __('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso'), |
|
| 223 | - ] |
|
| 224 | - ), |
|
| 225 | - new GraphQLField( |
|
| 226 | - 'isFree', |
|
| 227 | - [ |
|
| 228 | - 'key' => 'is_free', |
|
| 229 | - 'type' => 'Boolean', |
|
| 230 | - 'description' => __('Flag indicating whether the ticket is free.', 'event_espresso'), |
|
| 231 | - ] |
|
| 232 | - ), |
|
| 233 | - new GraphQLField( |
|
| 234 | - 'event', |
|
| 235 | - [ |
|
| 236 | - 'type' => 'Event', |
|
| 237 | - 'description' => __('Event of the ticket.', 'event_espresso'), |
|
| 238 | - ] |
|
| 239 | - ), |
|
| 240 | - ]; |
|
| 241 | - } |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + * @since $VID:$ |
|
| 57 | + */ |
|
| 58 | + public function getFields() |
|
| 59 | + { |
|
| 60 | + return [ |
|
| 61 | + new GraphQLField( |
|
| 62 | + 'id', |
|
| 63 | + [ |
|
| 64 | + 'key' => 'ID', |
|
| 65 | + 'type' => [ |
|
| 66 | + 'non_null' => 'Int', |
|
| 67 | + ], |
|
| 68 | + 'description' => __('Ticket ID', 'event_espresso'), |
|
| 69 | + ] |
|
| 70 | + ), |
|
| 71 | + new GraphQLField( |
|
| 72 | + 'name', |
|
| 73 | + [ |
|
| 74 | + 'key' => 'name', |
|
| 75 | + 'type' => 'String', |
|
| 76 | + 'description' => __('Ticket Name', 'event_espresso'), |
|
| 77 | + ] |
|
| 78 | + ), |
|
| 79 | + new GraphQLField( |
|
| 80 | + 'description', |
|
| 81 | + [ |
|
| 82 | + 'key' => 'description', |
|
| 83 | + 'type' => 'String', |
|
| 84 | + 'description' => __('Description of Ticket', 'event_espresso'), |
|
| 85 | + ] |
|
| 86 | + ), |
|
| 87 | + new GraphQLField( |
|
| 88 | + 'startDate', |
|
| 89 | + [ |
|
| 90 | + 'key' => 'start_date', |
|
| 91 | + 'type' => 'String', |
|
| 92 | + 'description' => __('Start time/date of Ticket', 'event_espresso'), |
|
| 93 | + ] |
|
| 94 | + ), |
|
| 95 | + new GraphQLField( |
|
| 96 | + 'endDate', |
|
| 97 | + [ |
|
| 98 | + 'key' => 'end_date', |
|
| 99 | + 'type' => 'String', |
|
| 100 | + 'description' => __('End time/date of Ticket', 'event_espresso'), |
|
| 101 | + ] |
|
| 102 | + ), |
|
| 103 | + new GraphQLField( |
|
| 104 | + 'min', |
|
| 105 | + [ |
|
| 106 | + 'key' => 'min', |
|
| 107 | + 'type' => 'Int', |
|
| 108 | + 'description' => __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), |
|
| 109 | + ] |
|
| 110 | + ), |
|
| 111 | + new GraphQLField( |
|
| 112 | + 'max', |
|
| 113 | + [ |
|
| 114 | + 'key' => 'max', |
|
| 115 | + 'type' => 'Int', |
|
| 116 | + 'description' => __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
| 117 | + 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 118 | + ] |
|
| 119 | + ), |
|
| 120 | + new GraphQLField( |
|
| 121 | + 'price', |
|
| 122 | + [ |
|
| 123 | + 'key' => 'price', |
|
| 124 | + 'type' => 'Float', |
|
| 125 | + 'description' => __('Final calculated price for ticket', 'event_espresso'), |
|
| 126 | + ] |
|
| 127 | + ), |
|
| 128 | + new GraphQLField( |
|
| 129 | + 'sold', |
|
| 130 | + [ |
|
| 131 | + 'key' => 'sold', |
|
| 132 | + 'type' => 'Int', |
|
| 133 | + 'description' => __('Number of this ticket sold', 'event_espresso'), |
|
| 134 | + ] |
|
| 135 | + ), |
|
| 136 | + new GraphQLField( |
|
| 137 | + 'quantity', |
|
| 138 | + [ |
|
| 139 | + 'key' => 'qty', |
|
| 140 | + 'type' => 'Int', |
|
| 141 | + 'description' => __('Quantity of this ticket that is available', 'event_espresso'), |
|
| 142 | + 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 143 | + ] |
|
| 144 | + ), |
|
| 145 | + new GraphQLField( |
|
| 146 | + 'reserved', |
|
| 147 | + [ |
|
| 148 | + 'key' => 'reserved', |
|
| 149 | + 'type' => 'Int', |
|
| 150 | + 'description' => __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso'), |
|
| 151 | + ] |
|
| 152 | + ), |
|
| 153 | + new GraphQLField( |
|
| 154 | + 'uses', |
|
| 155 | + [ |
|
| 156 | + 'key' => 'uses', |
|
| 157 | + 'type' => 'Int', |
|
| 158 | + 'description' => __('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 159 | + 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 160 | + ] |
|
| 161 | + ), |
|
| 162 | + new GraphQLField( |
|
| 163 | + 'isRequired', |
|
| 164 | + [ |
|
| 165 | + 'key' => 'required', |
|
| 166 | + 'type' => 'Boolean', |
|
| 167 | + 'description' => __('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso'), |
|
| 168 | + ] |
|
| 169 | + ), |
|
| 170 | + new GraphQLField( |
|
| 171 | + 'isTaxable', |
|
| 172 | + [ |
|
| 173 | + 'key' => 'taxable', |
|
| 174 | + 'type' => 'Boolean', |
|
| 175 | + 'description' => __('Flag indicating whether there is tax applied on this ticket', 'event_espresso'), |
|
| 176 | + ] |
|
| 177 | + ), |
|
| 178 | + new GraphQLField( |
|
| 179 | + 'isDefault', |
|
| 180 | + [ |
|
| 181 | + 'key' => 'is_default', |
|
| 182 | + 'type' => 'Boolean', |
|
| 183 | + 'description' => __('Flag indicating that this ticket is a default ticket', 'event_espresso'), |
|
| 184 | + ] |
|
| 185 | + ), |
|
| 186 | + new GraphQLField( |
|
| 187 | + 'order', |
|
| 188 | + [ |
|
| 189 | + 'key' => 'order', |
|
| 190 | + 'type' => 'Int', |
|
| 191 | + 'description' => __('The order in which the Datetime is displayed', 'event_espresso'), |
|
| 192 | + ] |
|
| 193 | + ), |
|
| 194 | + new GraphQLField( |
|
| 195 | + 'row', |
|
| 196 | + [ |
|
| 197 | + 'key' => 'row', |
|
| 198 | + 'type' => 'Int', |
|
| 199 | + 'description' => __('How tickets are displayed in the ui', 'event_espresso'), |
|
| 200 | + ] |
|
| 201 | + ), |
|
| 202 | + new GraphQLField( |
|
| 203 | + 'wpUser', |
|
| 204 | + [ |
|
| 205 | + 'type' => 'User', |
|
| 206 | + 'description' => __('Ticket Creator ID', 'event_espresso'), |
|
| 207 | + ] |
|
| 208 | + ), |
|
| 209 | + new GraphQLField( |
|
| 210 | + 'parent', |
|
| 211 | + [ |
|
| 212 | + 'key' => 'ID', |
|
| 213 | + 'type' => 'Ticket', |
|
| 214 | + 'description' => __('The parent ticket of the current ticket', 'event_espresso'), |
|
| 215 | + ] |
|
| 216 | + ), |
|
| 217 | + new GraphQLField( |
|
| 218 | + 'reverseCalculate', |
|
| 219 | + [ |
|
| 220 | + 'key' => 'reverse_calculate', |
|
| 221 | + 'type' => 'Boolean', |
|
| 222 | + 'description' => __('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso'), |
|
| 223 | + ] |
|
| 224 | + ), |
|
| 225 | + new GraphQLField( |
|
| 226 | + 'isFree', |
|
| 227 | + [ |
|
| 228 | + 'key' => 'is_free', |
|
| 229 | + 'type' => 'Boolean', |
|
| 230 | + 'description' => __('Flag indicating whether the ticket is free.', 'event_espresso'), |
|
| 231 | + ] |
|
| 232 | + ), |
|
| 233 | + new GraphQLField( |
|
| 234 | + 'event', |
|
| 235 | + [ |
|
| 236 | + 'type' => 'Event', |
|
| 237 | + 'description' => __('Event of the ticket.', 'event_espresso'), |
|
| 238 | + ] |
|
| 239 | + ), |
|
| 240 | + ]; |
|
| 241 | + } |
|
| 242 | 242 | } |
| 243 | 243 | \ No newline at end of file |
@@ -35,186 +35,186 @@ |
||
| 35 | 35 | class Venue extends TypeBase |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Venue constructor. |
|
| 40 | - * |
|
| 41 | - * @param EEM_Venue $venue_model |
|
| 42 | - */ |
|
| 43 | - public function __construct(EEM_Venue $venue_model) |
|
| 44 | - { |
|
| 45 | - $this->model = $venue_model; |
|
| 46 | - $this->setName('Venue'); |
|
| 47 | - $this->setIsCustomPostType(true); |
|
| 38 | + /** |
|
| 39 | + * Venue constructor. |
|
| 40 | + * |
|
| 41 | + * @param EEM_Venue $venue_model |
|
| 42 | + */ |
|
| 43 | + public function __construct(EEM_Venue $venue_model) |
|
| 44 | + { |
|
| 45 | + $this->model = $venue_model; |
|
| 46 | + $this->setName('Venue'); |
|
| 47 | + $this->setIsCustomPostType(true); |
|
| 48 | 48 | |
| 49 | - parent::__construct(); |
|
| 50 | - } |
|
| 49 | + parent::__construct(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return array |
|
| 55 | - * @since $VID:$ |
|
| 56 | - */ |
|
| 57 | - public function getFields() |
|
| 58 | - { |
|
| 59 | - return [ |
|
| 60 | - new GraphQLField( |
|
| 61 | - 'name', |
|
| 62 | - [ |
|
| 63 | - 'key' => 'name', |
|
| 64 | - 'type' => 'String', |
|
| 65 | - 'description' => __('Venue Name', 'event_espresso'), |
|
| 66 | - ] |
|
| 67 | - ), |
|
| 68 | - new GraphQLField( |
|
| 69 | - 'desc', |
|
| 70 | - [ |
|
| 71 | - 'key' => 'description', |
|
| 72 | - 'type' => 'String', |
|
| 73 | - 'description' => __('Venue Description', 'event_espresso'), |
|
| 74 | - ] |
|
| 75 | - ), |
|
| 76 | - new GraphQLField( |
|
| 77 | - 'shortDesc', |
|
| 78 | - [ |
|
| 79 | - 'key' => 'excerpt', |
|
| 80 | - 'type' => 'String', |
|
| 81 | - 'description' => __('Short Description of Venue', 'event_espresso'), |
|
| 82 | - ] |
|
| 83 | - ), |
|
| 84 | - new GraphQLField( |
|
| 85 | - 'identifier', |
|
| 86 | - [ |
|
| 87 | - 'key' => 'identifier', |
|
| 88 | - 'type' => 'String', |
|
| 89 | - 'description' => __('Venue Identifier', 'event_espresso'), |
|
| 90 | - ] |
|
| 91 | - ), |
|
| 92 | - new GraphQLField( |
|
| 93 | - 'created', |
|
| 94 | - [ |
|
| 95 | - 'key' => 'created', |
|
| 96 | - 'type' => 'String', |
|
| 97 | - 'description' => __('Date Venue Created', 'event_espresso'), |
|
| 98 | - ] |
|
| 99 | - ), |
|
| 100 | - new GraphQLField( |
|
| 101 | - 'order', |
|
| 102 | - [ |
|
| 103 | - 'key' => 'order', |
|
| 104 | - 'type' => 'Int', |
|
| 105 | - 'description' => __('Venue order', 'event_espresso'), |
|
| 106 | - ] |
|
| 107 | - ), |
|
| 108 | - new GraphQLField( |
|
| 109 | - 'wpUser', |
|
| 110 | - [ |
|
| 111 | - 'type' => 'User', |
|
| 112 | - 'description' => __('Venue Creator', 'event_espresso'), |
|
| 113 | - ] |
|
| 114 | - ), |
|
| 115 | - new GraphQLField( |
|
| 116 | - 'address', |
|
| 117 | - [ |
|
| 118 | - 'key' => 'address', |
|
| 119 | - 'type' => 'String', |
|
| 120 | - 'description' => __('Venue Address line 1', 'event_espresso'), |
|
| 121 | - ] |
|
| 122 | - ), |
|
| 123 | - new GraphQLField( |
|
| 124 | - 'address2', |
|
| 125 | - [ |
|
| 126 | - 'key' => 'address2', |
|
| 127 | - 'type' => 'String', |
|
| 128 | - 'description' => __('Venue Address line 2', 'event_espresso'), |
|
| 129 | - ] |
|
| 130 | - ), |
|
| 131 | - new GraphQLField( |
|
| 132 | - 'city', |
|
| 133 | - [ |
|
| 134 | - 'key' => 'city', |
|
| 135 | - 'type' => 'String', |
|
| 136 | - 'description' => __('Venue City', 'event_espresso'), |
|
| 137 | - ] |
|
| 138 | - ), |
|
| 139 | - new GraphQLField( |
|
| 140 | - 'state', |
|
| 141 | - [ |
|
| 142 | - 'type' => 'State', |
|
| 143 | - 'description' => __('Venue state', 'event_espresso'), |
|
| 144 | - ] |
|
| 145 | - ), |
|
| 146 | - new GraphQLField( |
|
| 147 | - 'country', |
|
| 148 | - [ |
|
| 149 | - 'type' => 'Country', |
|
| 150 | - 'description' => __('Venue country', 'event_espresso'), |
|
| 151 | - ] |
|
| 152 | - ), |
|
| 153 | - new GraphQLField( |
|
| 154 | - 'zip', |
|
| 155 | - [ |
|
| 156 | - 'key' => 'zip', |
|
| 157 | - 'type' => 'String', |
|
| 158 | - 'description' => __('Venue Zip/Postal Code', 'event_espresso'), |
|
| 159 | - ] |
|
| 160 | - ), |
|
| 161 | - new GraphQLField( |
|
| 162 | - 'capacity', |
|
| 163 | - [ |
|
| 164 | - 'key' => 'capacity', |
|
| 165 | - 'type' => 'Int', |
|
| 166 | - 'description' => __('Venue Capacity', 'event_espresso'), |
|
| 167 | - 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 168 | - ] |
|
| 169 | - ), |
|
| 170 | - new GraphQLField( |
|
| 171 | - 'phone', |
|
| 172 | - [ |
|
| 173 | - 'key' => 'phone', |
|
| 174 | - 'type' => 'String', |
|
| 175 | - 'description' => __('Venue Phone', 'event_espresso'), |
|
| 176 | - ] |
|
| 177 | - ), |
|
| 178 | - new GraphQLField( |
|
| 179 | - 'virtualPhone', |
|
| 180 | - [ |
|
| 181 | - 'key' => 'virtual_phone', |
|
| 182 | - 'type' => 'String', |
|
| 183 | - 'description' => __('Call in Number', 'event_espresso'), |
|
| 184 | - ] |
|
| 185 | - ), |
|
| 186 | - new GraphQLField( |
|
| 187 | - 'url', |
|
| 188 | - [ |
|
| 189 | - 'key' => 'venue_url', |
|
| 190 | - 'type' => 'String', |
|
| 191 | - 'description' => __('Venue Website', 'event_espresso'), |
|
| 192 | - ] |
|
| 193 | - ), |
|
| 194 | - new GraphQLField( |
|
| 195 | - 'virtualUrl', |
|
| 196 | - [ |
|
| 197 | - 'key' => 'virtual_url', |
|
| 198 | - 'type' => 'String', |
|
| 199 | - 'description' => __('Virtual URL', 'event_espresso'), |
|
| 200 | - ] |
|
| 201 | - ), |
|
| 202 | - new GraphQLField( |
|
| 203 | - 'googleMapLink', |
|
| 204 | - [ |
|
| 205 | - 'key' => 'google_map_link', |
|
| 206 | - 'type' => 'String', |
|
| 207 | - 'description' => __('Google Map Link', 'event_espresso'), |
|
| 208 | - ] |
|
| 209 | - ), |
|
| 210 | - new GraphQLField( |
|
| 211 | - 'enableForGmap', |
|
| 212 | - [ |
|
| 213 | - 'key' => 'enable_for_gmap', |
|
| 214 | - 'type' => 'String', |
|
| 215 | - 'description' => __('Show Google Map?', 'event_espresso'), |
|
| 216 | - ] |
|
| 217 | - ), |
|
| 218 | - ]; |
|
| 219 | - } |
|
| 53 | + /** |
|
| 54 | + * @return array |
|
| 55 | + * @since $VID:$ |
|
| 56 | + */ |
|
| 57 | + public function getFields() |
|
| 58 | + { |
|
| 59 | + return [ |
|
| 60 | + new GraphQLField( |
|
| 61 | + 'name', |
|
| 62 | + [ |
|
| 63 | + 'key' => 'name', |
|
| 64 | + 'type' => 'String', |
|
| 65 | + 'description' => __('Venue Name', 'event_espresso'), |
|
| 66 | + ] |
|
| 67 | + ), |
|
| 68 | + new GraphQLField( |
|
| 69 | + 'desc', |
|
| 70 | + [ |
|
| 71 | + 'key' => 'description', |
|
| 72 | + 'type' => 'String', |
|
| 73 | + 'description' => __('Venue Description', 'event_espresso'), |
|
| 74 | + ] |
|
| 75 | + ), |
|
| 76 | + new GraphQLField( |
|
| 77 | + 'shortDesc', |
|
| 78 | + [ |
|
| 79 | + 'key' => 'excerpt', |
|
| 80 | + 'type' => 'String', |
|
| 81 | + 'description' => __('Short Description of Venue', 'event_espresso'), |
|
| 82 | + ] |
|
| 83 | + ), |
|
| 84 | + new GraphQLField( |
|
| 85 | + 'identifier', |
|
| 86 | + [ |
|
| 87 | + 'key' => 'identifier', |
|
| 88 | + 'type' => 'String', |
|
| 89 | + 'description' => __('Venue Identifier', 'event_espresso'), |
|
| 90 | + ] |
|
| 91 | + ), |
|
| 92 | + new GraphQLField( |
|
| 93 | + 'created', |
|
| 94 | + [ |
|
| 95 | + 'key' => 'created', |
|
| 96 | + 'type' => 'String', |
|
| 97 | + 'description' => __('Date Venue Created', 'event_espresso'), |
|
| 98 | + ] |
|
| 99 | + ), |
|
| 100 | + new GraphQLField( |
|
| 101 | + 'order', |
|
| 102 | + [ |
|
| 103 | + 'key' => 'order', |
|
| 104 | + 'type' => 'Int', |
|
| 105 | + 'description' => __('Venue order', 'event_espresso'), |
|
| 106 | + ] |
|
| 107 | + ), |
|
| 108 | + new GraphQLField( |
|
| 109 | + 'wpUser', |
|
| 110 | + [ |
|
| 111 | + 'type' => 'User', |
|
| 112 | + 'description' => __('Venue Creator', 'event_espresso'), |
|
| 113 | + ] |
|
| 114 | + ), |
|
| 115 | + new GraphQLField( |
|
| 116 | + 'address', |
|
| 117 | + [ |
|
| 118 | + 'key' => 'address', |
|
| 119 | + 'type' => 'String', |
|
| 120 | + 'description' => __('Venue Address line 1', 'event_espresso'), |
|
| 121 | + ] |
|
| 122 | + ), |
|
| 123 | + new GraphQLField( |
|
| 124 | + 'address2', |
|
| 125 | + [ |
|
| 126 | + 'key' => 'address2', |
|
| 127 | + 'type' => 'String', |
|
| 128 | + 'description' => __('Venue Address line 2', 'event_espresso'), |
|
| 129 | + ] |
|
| 130 | + ), |
|
| 131 | + new GraphQLField( |
|
| 132 | + 'city', |
|
| 133 | + [ |
|
| 134 | + 'key' => 'city', |
|
| 135 | + 'type' => 'String', |
|
| 136 | + 'description' => __('Venue City', 'event_espresso'), |
|
| 137 | + ] |
|
| 138 | + ), |
|
| 139 | + new GraphQLField( |
|
| 140 | + 'state', |
|
| 141 | + [ |
|
| 142 | + 'type' => 'State', |
|
| 143 | + 'description' => __('Venue state', 'event_espresso'), |
|
| 144 | + ] |
|
| 145 | + ), |
|
| 146 | + new GraphQLField( |
|
| 147 | + 'country', |
|
| 148 | + [ |
|
| 149 | + 'type' => 'Country', |
|
| 150 | + 'description' => __('Venue country', 'event_espresso'), |
|
| 151 | + ] |
|
| 152 | + ), |
|
| 153 | + new GraphQLField( |
|
| 154 | + 'zip', |
|
| 155 | + [ |
|
| 156 | + 'key' => 'zip', |
|
| 157 | + 'type' => 'String', |
|
| 158 | + 'description' => __('Venue Zip/Postal Code', 'event_espresso'), |
|
| 159 | + ] |
|
| 160 | + ), |
|
| 161 | + new GraphQLField( |
|
| 162 | + 'capacity', |
|
| 163 | + [ |
|
| 164 | + 'key' => 'capacity', |
|
| 165 | + 'type' => 'Int', |
|
| 166 | + 'description' => __('Venue Capacity', 'event_espresso'), |
|
| 167 | + 'formatCallback' => [$this, 'parseInfiniteValue'], |
|
| 168 | + ] |
|
| 169 | + ), |
|
| 170 | + new GraphQLField( |
|
| 171 | + 'phone', |
|
| 172 | + [ |
|
| 173 | + 'key' => 'phone', |
|
| 174 | + 'type' => 'String', |
|
| 175 | + 'description' => __('Venue Phone', 'event_espresso'), |
|
| 176 | + ] |
|
| 177 | + ), |
|
| 178 | + new GraphQLField( |
|
| 179 | + 'virtualPhone', |
|
| 180 | + [ |
|
| 181 | + 'key' => 'virtual_phone', |
|
| 182 | + 'type' => 'String', |
|
| 183 | + 'description' => __('Call in Number', 'event_espresso'), |
|
| 184 | + ] |
|
| 185 | + ), |
|
| 186 | + new GraphQLField( |
|
| 187 | + 'url', |
|
| 188 | + [ |
|
| 189 | + 'key' => 'venue_url', |
|
| 190 | + 'type' => 'String', |
|
| 191 | + 'description' => __('Venue Website', 'event_espresso'), |
|
| 192 | + ] |
|
| 193 | + ), |
|
| 194 | + new GraphQLField( |
|
| 195 | + 'virtualUrl', |
|
| 196 | + [ |
|
| 197 | + 'key' => 'virtual_url', |
|
| 198 | + 'type' => 'String', |
|
| 199 | + 'description' => __('Virtual URL', 'event_espresso'), |
|
| 200 | + ] |
|
| 201 | + ), |
|
| 202 | + new GraphQLField( |
|
| 203 | + 'googleMapLink', |
|
| 204 | + [ |
|
| 205 | + 'key' => 'google_map_link', |
|
| 206 | + 'type' => 'String', |
|
| 207 | + 'description' => __('Google Map Link', 'event_espresso'), |
|
| 208 | + ] |
|
| 209 | + ), |
|
| 210 | + new GraphQLField( |
|
| 211 | + 'enableForGmap', |
|
| 212 | + [ |
|
| 213 | + 'key' => 'enable_for_gmap', |
|
| 214 | + 'type' => 'String', |
|
| 215 | + 'description' => __('Show Google Map?', 'event_espresso'), |
|
| 216 | + ] |
|
| 217 | + ), |
|
| 218 | + ]; |
|
| 219 | + } |
|
| 220 | 220 | } |
| 221 | 221 | \ No newline at end of file |