Completed
Branch master (87a62b)
by
unknown
18:29 queued 13:45
created
core/domain/services/graphql/inputs/StatesConnectionOrderbyInput.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'StatesConnectionOrderbyInput');
25
+        $this->setName($this->namespace.'StatesConnectionOrderbyInput');
26 26
         $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27 27
         parent::__construct();
28 28
     }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         return [
37 37
             new GraphQLField(
38 38
                 'field',
39
-                ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum']
39
+                ['non_null' => $this->namespace.'StatesConnectionOrderbyEnum']
40 40
             ),
41 41
             new GraphQLField(
42 42
                 'order',
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@
 block discarded – undo
16 16
  */
17 17
 class StatesConnectionOrderbyInput extends InputBase
18 18
 {
19
-    /**
20
-     * StatesConnectionOrderbyInput constructor.
21
-     */
22
-    public function __construct()
23
-    {
24
-        $this->setName($this->namespace . 'StatesConnectionOrderbyInput');
25
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
26
-        parent::__construct();
27
-    }
19
+	/**
20
+	 * StatesConnectionOrderbyInput constructor.
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$this->setName($this->namespace . 'StatesConnectionOrderbyInput');
25
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
26
+		parent::__construct();
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @return GraphQLFieldInterface[]
32
-     */
33
-    protected function getFields(): array
34
-    {
35
-        return [
36
-            new GraphQLField(
37
-                'field',
38
-                ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum']
39
-            ),
40
-            new GraphQLField(
41
-                'order',
42
-                'OrderEnum'
43
-            ),
44
-        ];
45
-    }
30
+	/**
31
+	 * @return GraphQLFieldInterface[]
32
+	 */
33
+	protected function getFields(): array
34
+	{
35
+		return [
36
+			new GraphQLField(
37
+				'field',
38
+				['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum']
39
+			),
40
+			new GraphQLField(
41
+				'order',
42
+				'OrderEnum'
43
+			),
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/inputs/CountriesConnectionOrderbyInput.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'CountriesConnectionOrderbyInput');
25
+        $this->setName($this->namespace.'CountriesConnectionOrderbyInput');
26 26
         $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
27 27
         parent::__construct();
28 28
     }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         return [
37 37
             new GraphQLField(
38 38
                 'field',
39
-                ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum']
39
+                ['non_null' => $this->namespace.'CountriesConnectionOrderbyEnum']
40 40
             ),
41 41
             new GraphQLField(
42 42
                 'order',
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@
 block discarded – undo
16 16
  */
17 17
 class CountriesConnectionOrderbyInput extends InputBase
18 18
 {
19
-    /**
20
-     * CountriesConnectionOrderbyInput constructor.
21
-     */
22
-    public function __construct()
23
-    {
24
-        $this->setName($this->namespace . 'CountriesConnectionOrderbyInput');
25
-        $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
26
-        parent::__construct();
27
-    }
19
+	/**
20
+	 * CountriesConnectionOrderbyInput constructor.
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$this->setName($this->namespace . 'CountriesConnectionOrderbyInput');
25
+		$this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso'));
26
+		parent::__construct();
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @return GraphQLFieldInterface[]
32
-     */
33
-    protected function getFields(): array
34
-    {
35
-        return [
36
-            new GraphQLField(
37
-                'field',
38
-                ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum']
39
-            ),
40
-            new GraphQLField(
41
-                'order',
42
-                'OrderEnum'
43
-            ),
44
-        ];
45
-    }
30
+	/**
31
+	 * @return GraphQLFieldInterface[]
32
+	 */
33
+	protected function getFields(): array
34
+	{
35
+		return [
36
+			new GraphQLField(
37
+				'field',
38
+				['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum']
39
+			),
40
+			new GraphQLField(
41
+				'order',
42
+				'OrderEnum'
43
+			),
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/CountryLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class CountryLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base|EEM_Country
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Country::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base|EEM_Country
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Country::instance();
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param array $keys
34
-     * @return array
35
-     */
36
-    protected function getWhereParams(array $keys): array
37
-    {
38
-        return [
39
-            'CNT_ISO' => ['IN', $keys],
40
-        ];
41
-    }
32
+	/**
33
+	 * @param array $keys
34
+	 * @return array
35
+	 */
36
+	protected function getWhereParams(array $keys): array
37
+	{
38
+		return [
39
+			'CNT_ISO' => ['IN', $keys],
40
+		];
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/StateLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class StateLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base|EEM_State
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_State::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base|EEM_State
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_State::instance();
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param array $keys
34
-     * @return array
35
-     */
36
-    protected function getWhereParams(array $keys): array
37
-    {
38
-        return [
39
-            'STA_ID' => ['IN', $keys],
40
-        ];
41
-    }
32
+	/**
33
+	 * @param array $keys
34
+	 * @return array
35
+	 */
36
+	protected function getWhereParams(array $keys): array
37
+	{
38
+		return [
39
+			'STA_ID' => ['IN', $keys],
40
+		];
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/CountriesConnectionOrderbyEnum.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct()
22 22
     {
23
-        $this->setName($this->namespace . 'CountriesConnectionOrderbyEnum');
23
+        $this->setName($this->namespace.'CountriesConnectionOrderbyEnum');
24 24
         $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
25 25
         parent::__construct();
26 26
     }
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@
 block discarded – undo
14 14
  */
15 15
 class CountriesConnectionOrderbyEnum extends EnumBase
16 16
 {
17
-    /**
18
-     * CountriesConnectionOrderbyEnum constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->setName($this->namespace . 'CountriesConnectionOrderbyEnum');
23
-        $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
24
-        parent::__construct();
25
-    }
17
+	/**
18
+	 * CountriesConnectionOrderbyEnum constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->setName($this->namespace . 'CountriesConnectionOrderbyEnum');
23
+		$this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
24
+		parent::__construct();
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * @return array
30
-     */
31
-    protected function getValues(): array
32
-    {
33
-        return [
34
-            'NAME'     => [
35
-                'value'       => 'CNT_name',
36
-                'description' => esc_html__('Order by country name', 'event_espresso'),
37
-            ],
38
-            'ISO'     => [
39
-                'value'       => 'CNT_ISO',
40
-                'description' => esc_html__('Order by country ISO', 'event_espresso'),
41
-            ],
42
-            'CNT_ISO3'     => [
43
-                'value'       => 'CNT_ISO3',
44
-                'description' => esc_html__('Order by country ISO3', 'event_espresso'),
45
-            ],
46
-        ];
47
-    }
28
+	/**
29
+	 * @return array
30
+	 */
31
+	protected function getValues(): array
32
+	{
33
+		return [
34
+			'NAME'     => [
35
+				'value'       => 'CNT_name',
36
+				'description' => esc_html__('Order by country name', 'event_espresso'),
37
+			],
38
+			'ISO'     => [
39
+				'value'       => 'CNT_ISO',
40
+				'description' => esc_html__('Order by country ISO', 'event_espresso'),
41
+			],
42
+			'CNT_ISO3'     => [
43
+				'value'       => 'CNT_ISO3',
44
+				'description' => esc_html__('Order by country ISO3', 'event_espresso'),
45
+			],
46
+		];
47
+	}
48 48
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/StatesConnectionOrderbyEnum.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct()
22 22
     {
23
-        $this->setName($this->namespace . 'StatesConnectionOrderbyEnum');
23
+        $this->setName($this->namespace.'StatesConnectionOrderbyEnum');
24 24
         $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
25 25
         parent::__construct();
26 26
     }
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@
 block discarded – undo
14 14
  */
15 15
 class StatesConnectionOrderbyEnum extends EnumBase
16 16
 {
17
-    /**
18
-     * StatesConnectionOrderbyEnum constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->setName($this->namespace . 'StatesConnectionOrderbyEnum');
23
-        $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
24
-        parent::__construct();
25
-    }
17
+	/**
18
+	 * StatesConnectionOrderbyEnum constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->setName($this->namespace . 'StatesConnectionOrderbyEnum');
23
+		$this->setDescription(esc_html__('Field to order the connection by', 'event_espresso'));
24
+		parent::__construct();
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * @return array
30
-     */
31
-    protected function getValues(): array
32
-    {
33
-        return [
34
-            'NAME'     => [
35
-                'value'       => 'CNT_name',
36
-                'description' => esc_html__('Order by state name', 'event_espresso'),
37
-            ],
38
-            'COUNTRY_ISO'     => [
39
-                'value'       => 'CNT_ISO',
40
-                'description' => esc_html__('Order by country ISO', 'event_espresso'),
41
-            ],
42
-        ];
43
-    }
28
+	/**
29
+	 * @return array
30
+	 */
31
+	protected function getValues(): array
32
+	{
33
+		return [
34
+			'NAME'     => [
35
+				'value'       => 'CNT_name',
36
+				'description' => esc_html__('Order by state name', 'event_espresso'),
37
+			],
38
+			'COUNTRY_ISO'     => [
39
+				'value'       => 'CNT_ISO',
40
+				'description' => esc_html__('Order by country ISO', 'event_espresso'),
41
+			],
42
+		];
43
+	}
44 44
 }
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/StateConnectionResolver.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -14,152 +14,152 @@
 block discarded – undo
14 14
  */
15 15
 class StateConnectionResolver extends AbstractConnectionResolver
16 16
 {
17
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
-    public function get_loader_name(): string
19
-    {
20
-        return 'espresso_state';
21
-    }
22
-
23
-    /**
24
-     * @return EEM_State
25
-     * @throws EE_Error
26
-     * @throws InvalidArgumentException
27
-     * @throws InvalidDataTypeException
28
-     * @throws InvalidInterfaceException
29
-     * @throws ReflectionException
30
-     */
31
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
-    public function get_query(): EEM_State
33
-    {
34
-        return EEM_State::instance();
35
-    }
36
-
37
-
38
-    /**
39
-     * Return an array of item IDs from the query
40
-     *
41
-     * @return array
42
-     */
43
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
-    public function get_ids(): array
45
-    {
46
-        $results = $this->query->get_col($this->query_args);
47
-
48
-        return ! empty($results) ? $results : [];
49
-    }
50
-
51
-
52
-    /**
53
-     * Here, we map the args from the input, then we make sure that we're only querying
54
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
55
-     * handle batch resolution of the posts.
56
-     *
57
-     * @return array
58
-     * @throws InvalidArgumentException
59
-     * @throws InvalidDataTypeException
60
-     * @throws InvalidInterfaceException
61
-     */
62
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
-    public function get_query_args(): array
64
-    {
65
-        $where_params = [];
66
-        $query_args   = [];
67
-
68
-        $query_args['limit'] = $this->getLimit();
69
-
70
-        // Avoid multiple entries by join.
71
-        $query_args['group_by'] = 'STA_ID';
72
-
73
-        $query_args['default_where_conditions'] = 'minimum';
74
-
75
-        /**
76
-         * Collect the input_fields and sanitize them to prepare them for sending to the Query
77
-         */
78
-        $input_fields = [];
79
-        if (! empty($this->args['where'])) {
80
-            $input_fields = $this->sanitizeInputFields($this->args['where']);
81
-
82
-            // Since we do not have any falsy values in query params
83
-            // Lets get rid of empty values
84
-            $input_fields = array_filter($input_fields);
85
-
86
-            // Use the proper operator.
87
-            if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) {
88
-                $input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']];
89
-            }
90
-            if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
91
-                $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
92
-            }
93
-        }
94
-
95
-        /**
96
-         * Merge the input_fields with the default query_args
97
-         */
98
-        if (! empty($input_fields)) {
99
-            $where_params = array_merge($where_params, $input_fields);
100
-        }
101
-
102
-        // limit to active countries by default.
103
-        if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
104
-            $where_params['STA_active'] = true;
105
-        }
106
-
107
-        [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'STA_ID');
108
-
109
-        if (empty($query_args['order_by'])) {
110
-            // set order_by to 'name' by default
111
-            $query_args['order_by'] = [
112
-                'STA_name' => 'ASC',
113
-            ];
114
-        }
115
-
116
-        $search = $this->getSearchKeywords($this->args['where']);
117
-
118
-        if (! empty($search)) {
119
-            // use OR operator to search in any of the fields
120
-            $where_params['OR'] = array(
121
-                'STA_name' => array('LIKE', '%' . $search . '%'),
122
-            );
123
-        }
124
-
125
-        $where_params = apply_filters(
126
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_where_params',
127
-            $where_params,
128
-            $this->source,
129
-            $this->args
130
-        );
131
-
132
-        $query_args[] = $where_params;
133
-
134
-        /**
135
-         * Return the $query_args
136
-         */
137
-        return apply_filters(
138
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_query_args',
139
-            $query_args,
140
-            $this->source,
141
-            $this->args
142
-        );
143
-    }
144
-
145
-
146
-    /**
147
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
148
-     * friendly keys.
149
-     *
150
-     * @param array $where_args
151
-     * @return array
152
-     */
153
-    public function sanitizeInputFields(array $where_args): array
154
-    {
155
-        $arg_mapping = [
156
-            'in'           => 'STA_ID',
157
-            'countryIsoIn' => 'CNT_ISO',
158
-        ];
159
-        return $this->sanitizeWhereArgsForInputFields(
160
-            $where_args,
161
-            $arg_mapping,
162
-            ['in']
163
-        );
164
-    }
17
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
+	public function get_loader_name(): string
19
+	{
20
+		return 'espresso_state';
21
+	}
22
+
23
+	/**
24
+	 * @return EEM_State
25
+	 * @throws EE_Error
26
+	 * @throws InvalidArgumentException
27
+	 * @throws InvalidDataTypeException
28
+	 * @throws InvalidInterfaceException
29
+	 * @throws ReflectionException
30
+	 */
31
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
+	public function get_query(): EEM_State
33
+	{
34
+		return EEM_State::instance();
35
+	}
36
+
37
+
38
+	/**
39
+	 * Return an array of item IDs from the query
40
+	 *
41
+	 * @return array
42
+	 */
43
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
+	public function get_ids(): array
45
+	{
46
+		$results = $this->query->get_col($this->query_args);
47
+
48
+		return ! empty($results) ? $results : [];
49
+	}
50
+
51
+
52
+	/**
53
+	 * Here, we map the args from the input, then we make sure that we're only querying
54
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
55
+	 * handle batch resolution of the posts.
56
+	 *
57
+	 * @return array
58
+	 * @throws InvalidArgumentException
59
+	 * @throws InvalidDataTypeException
60
+	 * @throws InvalidInterfaceException
61
+	 */
62
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
+	public function get_query_args(): array
64
+	{
65
+		$where_params = [];
66
+		$query_args   = [];
67
+
68
+		$query_args['limit'] = $this->getLimit();
69
+
70
+		// Avoid multiple entries by join.
71
+		$query_args['group_by'] = 'STA_ID';
72
+
73
+		$query_args['default_where_conditions'] = 'minimum';
74
+
75
+		/**
76
+		 * Collect the input_fields and sanitize them to prepare them for sending to the Query
77
+		 */
78
+		$input_fields = [];
79
+		if (! empty($this->args['where'])) {
80
+			$input_fields = $this->sanitizeInputFields($this->args['where']);
81
+
82
+			// Since we do not have any falsy values in query params
83
+			// Lets get rid of empty values
84
+			$input_fields = array_filter($input_fields);
85
+
86
+			// Use the proper operator.
87
+			if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) {
88
+				$input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']];
89
+			}
90
+			if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
91
+				$input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
92
+			}
93
+		}
94
+
95
+		/**
96
+		 * Merge the input_fields with the default query_args
97
+		 */
98
+		if (! empty($input_fields)) {
99
+			$where_params = array_merge($where_params, $input_fields);
100
+		}
101
+
102
+		// limit to active countries by default.
103
+		if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
104
+			$where_params['STA_active'] = true;
105
+		}
106
+
107
+		[$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'STA_ID');
108
+
109
+		if (empty($query_args['order_by'])) {
110
+			// set order_by to 'name' by default
111
+			$query_args['order_by'] = [
112
+				'STA_name' => 'ASC',
113
+			];
114
+		}
115
+
116
+		$search = $this->getSearchKeywords($this->args['where']);
117
+
118
+		if (! empty($search)) {
119
+			// use OR operator to search in any of the fields
120
+			$where_params['OR'] = array(
121
+				'STA_name' => array('LIKE', '%' . $search . '%'),
122
+			);
123
+		}
124
+
125
+		$where_params = apply_filters(
126
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_where_params',
127
+			$where_params,
128
+			$this->source,
129
+			$this->args
130
+		);
131
+
132
+		$query_args[] = $where_params;
133
+
134
+		/**
135
+		 * Return the $query_args
136
+		 */
137
+		return apply_filters(
138
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_query_args',
139
+			$query_args,
140
+			$this->source,
141
+			$this->args
142
+		);
143
+	}
144
+
145
+
146
+	/**
147
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
148
+	 * friendly keys.
149
+	 *
150
+	 * @param array $where_args
151
+	 * @return array
152
+	 */
153
+	public function sanitizeInputFields(array $where_args): array
154
+	{
155
+		$arg_mapping = [
156
+			'in'           => 'STA_ID',
157
+			'countryIsoIn' => 'CNT_ISO',
158
+		];
159
+		return $this->sanitizeWhereArgsForInputFields(
160
+			$where_args,
161
+			$arg_mapping,
162
+			['in']
163
+		);
164
+	}
165 165
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
          * Collect the input_fields and sanitize them to prepare them for sending to the Query
77 77
          */
78 78
         $input_fields = [];
79
-        if (! empty($this->args['where'])) {
79
+        if ( ! empty($this->args['where'])) {
80 80
             $input_fields = $this->sanitizeInputFields($this->args['where']);
81 81
 
82 82
             // Since we do not have any falsy values in query params
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
             $input_fields = array_filter($input_fields);
85 85
 
86 86
             // Use the proper operator.
87
-            if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) {
87
+            if ( ! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) {
88 88
                 $input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']];
89 89
             }
90
-            if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
90
+            if ( ! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
91 91
                 $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
92 92
             }
93 93
         }
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
         /**
96 96
          * Merge the input_fields with the default query_args
97 97
          */
98
-        if (! empty($input_fields)) {
98
+        if ( ! empty($input_fields)) {
99 99
             $where_params = array_merge($where_params, $input_fields);
100 100
         }
101 101
 
102 102
         // limit to active countries by default.
103
-        if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
103
+        if ( ! isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
104 104
             $where_params['STA_active'] = true;
105 105
         }
106 106
 
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 
116 116
         $search = $this->getSearchKeywords($this->args['where']);
117 117
 
118
-        if (! empty($search)) {
118
+        if ( ! empty($search)) {
119 119
             // use OR operator to search in any of the fields
120 120
             $where_params['OR'] = array(
121
-                'STA_name' => array('LIKE', '%' . $search . '%'),
121
+                'STA_name' => array('LIKE', '%'.$search.'%'),
122 122
             );
123 123
         }
124 124
 
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/CountryConnectionResolver.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
          * Collect the input_fields and sanitize them to prepare them for sending to the Query
95 95
          */
96 96
         $input_fields = [];
97
-        if (! empty($this->args['where'])) {
97
+        if ( ! empty($this->args['where'])) {
98 98
             $input_fields = $this->sanitizeInputFields($this->args['where']);
99 99
 
100 100
             // Since we do not have any falsy values in query params
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
             $input_fields = array_filter($input_fields);
103 103
 
104 104
             // Use the proper operator.
105
-            if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
105
+            if ( ! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
106 106
                 $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
107 107
             }
108
-            if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) {
108
+            if ( ! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) {
109 109
                 $input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']];
110 110
             }
111 111
         }
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
         /**
114 114
          * Merge the input_fields with the default query_args
115 115
          */
116
-        if (! empty($input_fields)) {
116
+        if ( ! empty($input_fields)) {
117 117
             $where_params = array_merge($where_params, $input_fields);
118 118
         }
119 119
 
120 120
         // limit to active countries by default.
121
-        if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
121
+        if ( ! isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
122 122
             $where_params['CNT_active'] = true;
123 123
         }
124 124
 
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 
134 134
         $search = $this->getSearchKeywords($this->args['where']);
135 135
 
136
-        if (! empty($search)) {
136
+        if ( ! empty($search)) {
137 137
             // use OR operator to search in any of the fields
138 138
             $where_params['OR'] = array(
139
-                'CNT_name' => array('LIKE', '%' . $search . '%'),
140
-                'CNT_ISO'  => array('LIKE', '%' . $search . '%'),
139
+                'CNT_name' => array('LIKE', '%'.$search.'%'),
140
+                'CNT_ISO'  => array('LIKE', '%'.$search.'%'),
141 141
             );
142 142
         }
143 143
 
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -16,170 +16,170 @@
 block discarded – undo
16 16
  */
17 17
 class CountryConnectionResolver extends AbstractConnectionResolver
18 18
 {
19
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
20
-    public function get_loader_name(): string
21
-    {
22
-        return 'espresso_country';
23
-    }
24
-
25
-    /**
26
-     * @return EEM_Country
27
-     * @throws EE_Error
28
-     * @throws InvalidArgumentException
29
-     * @throws InvalidDataTypeException
30
-     * @throws InvalidInterfaceException
31
-     * @throws ReflectionException
32
-     */
33
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
34
-    public function get_query(): EEM_Country
35
-    {
36
-        return EEM_Country::instance();
37
-    }
38
-
39
-
40
-    /**
41
-     * Return an array of item IDs from the query
42
-     *
43
-     * @return array
44
-     */
45
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
-    public function get_ids(): array
47
-    {
48
-        $results = $this->query->get_col($this->query_args);
49
-
50
-        return ! empty($results) ? $results : [];
51
-    }
52
-
53
-    /**
54
-     * Get_query_amount
55
-     *
56
-     * Returns the max between what was requested and what is defined as the $max_query_amount to
57
-     * ensure that queries don't exceed unwanted limits when querying data.
58
-     *
59
-     * @return int
60
-     * @throws Exception
61
-     */
62
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
-    public function get_query_amount()
64
-    {
65
-        // Override the default limit (100) for countries
66
-        return 500;
67
-    }
68
-
69
-
70
-    /**
71
-     * Here, we map the args from the input, then we make sure that we're only querying
72
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
73
-     * handle batch resolution of the posts.
74
-     *
75
-     * @return array
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidInterfaceException
79
-     */
80
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
81
-    public function get_query_args(): array
82
-    {
83
-        $where_params = [];
84
-        $query_args   = [];
85
-
86
-        $query_args['limit'] = $this->getLimit();
87
-
88
-        // Avoid multiple entries by join.
89
-        $query_args['group_by'] = 'CNT_ISO';
90
-
91
-        $query_args['default_where_conditions'] = 'minimum';
92
-
93
-        /**
94
-         * Collect the input_fields and sanitize them to prepare them for sending to the Query
95
-         */
96
-        $input_fields = [];
97
-        if (! empty($this->args['where'])) {
98
-            $input_fields = $this->sanitizeInputFields($this->args['where']);
99
-
100
-            // Since we do not have any falsy values in query params
101
-            // Lets get rid of empty values
102
-            $input_fields = array_filter($input_fields);
103
-
104
-            // Use the proper operator.
105
-            if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
106
-                $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
107
-            }
108
-            if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) {
109
-                $input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']];
110
-            }
111
-        }
112
-
113
-        /**
114
-         * Merge the input_fields with the default query_args
115
-         */
116
-        if (! empty($input_fields)) {
117
-            $where_params = array_merge($where_params, $input_fields);
118
-        }
119
-
120
-        // limit to active countries by default.
121
-        if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
122
-            $where_params['CNT_active'] = true;
123
-        }
124
-
125
-        [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'CNT_ISO');
126
-
127
-        if (empty($query_args['order_by'])) {
128
-            // set order_by to 'name' by default
129
-            $query_args['order_by'] = [
130
-                'CNT_name' => 'ASC',
131
-            ];
132
-        }
133
-
134
-        $search = $this->getSearchKeywords($this->args['where']);
135
-
136
-        if (! empty($search)) {
137
-            // use OR operator to search in any of the fields
138
-            $where_params['OR'] = array(
139
-                'CNT_name' => array('LIKE', '%' . $search . '%'),
140
-                'CNT_ISO'  => array('LIKE', '%' . $search . '%'),
141
-            );
142
-        }
143
-
144
-        $where_params = apply_filters(
145
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_where_params',
146
-            $where_params,
147
-            $this->source,
148
-            $this->args
149
-        );
150
-
151
-        $query_args[] = $where_params;
152
-
153
-        /**
154
-         * Return the $query_args
155
-         */
156
-        return apply_filters(
157
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_query_args',
158
-            $query_args,
159
-            $this->source,
160
-            $this->args
161
-        );
162
-    }
163
-
164
-
165
-    /**
166
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
167
-     * friendly keys.
168
-     *
169
-     * @param array $where_args
170
-     * @return array
171
-     */
172
-    public function sanitizeInputFields(array $where_args): array
173
-    {
174
-        $arg_mapping = [
175
-            'isoIn'  => 'CNT_ISO',
176
-            'in'     => 'CNT_ISO',
177
-            'iso3In' => 'CNT_ISO3',
178
-        ];
179
-        return $this->sanitizeWhereArgsForInputFields(
180
-            $where_args,
181
-            $arg_mapping,
182
-            ['in']
183
-        );
184
-    }
19
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
20
+	public function get_loader_name(): string
21
+	{
22
+		return 'espresso_country';
23
+	}
24
+
25
+	/**
26
+	 * @return EEM_Country
27
+	 * @throws EE_Error
28
+	 * @throws InvalidArgumentException
29
+	 * @throws InvalidDataTypeException
30
+	 * @throws InvalidInterfaceException
31
+	 * @throws ReflectionException
32
+	 */
33
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
34
+	public function get_query(): EEM_Country
35
+	{
36
+		return EEM_Country::instance();
37
+	}
38
+
39
+
40
+	/**
41
+	 * Return an array of item IDs from the query
42
+	 *
43
+	 * @return array
44
+	 */
45
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
+	public function get_ids(): array
47
+	{
48
+		$results = $this->query->get_col($this->query_args);
49
+
50
+		return ! empty($results) ? $results : [];
51
+	}
52
+
53
+	/**
54
+	 * Get_query_amount
55
+	 *
56
+	 * Returns the max between what was requested and what is defined as the $max_query_amount to
57
+	 * ensure that queries don't exceed unwanted limits when querying data.
58
+	 *
59
+	 * @return int
60
+	 * @throws Exception
61
+	 */
62
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
+	public function get_query_amount()
64
+	{
65
+		// Override the default limit (100) for countries
66
+		return 500;
67
+	}
68
+
69
+
70
+	/**
71
+	 * Here, we map the args from the input, then we make sure that we're only querying
72
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
73
+	 * handle batch resolution of the posts.
74
+	 *
75
+	 * @return array
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidInterfaceException
79
+	 */
80
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
81
+	public function get_query_args(): array
82
+	{
83
+		$where_params = [];
84
+		$query_args   = [];
85
+
86
+		$query_args['limit'] = $this->getLimit();
87
+
88
+		// Avoid multiple entries by join.
89
+		$query_args['group_by'] = 'CNT_ISO';
90
+
91
+		$query_args['default_where_conditions'] = 'minimum';
92
+
93
+		/**
94
+		 * Collect the input_fields and sanitize them to prepare them for sending to the Query
95
+		 */
96
+		$input_fields = [];
97
+		if (! empty($this->args['where'])) {
98
+			$input_fields = $this->sanitizeInputFields($this->args['where']);
99
+
100
+			// Since we do not have any falsy values in query params
101
+			// Lets get rid of empty values
102
+			$input_fields = array_filter($input_fields);
103
+
104
+			// Use the proper operator.
105
+			if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) {
106
+				$input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']];
107
+			}
108
+			if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) {
109
+				$input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']];
110
+			}
111
+		}
112
+
113
+		/**
114
+		 * Merge the input_fields with the default query_args
115
+		 */
116
+		if (! empty($input_fields)) {
117
+			$where_params = array_merge($where_params, $input_fields);
118
+		}
119
+
120
+		// limit to active countries by default.
121
+		if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) {
122
+			$where_params['CNT_active'] = true;
123
+		}
124
+
125
+		[$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'CNT_ISO');
126
+
127
+		if (empty($query_args['order_by'])) {
128
+			// set order_by to 'name' by default
129
+			$query_args['order_by'] = [
130
+				'CNT_name' => 'ASC',
131
+			];
132
+		}
133
+
134
+		$search = $this->getSearchKeywords($this->args['where']);
135
+
136
+		if (! empty($search)) {
137
+			// use OR operator to search in any of the fields
138
+			$where_params['OR'] = array(
139
+				'CNT_name' => array('LIKE', '%' . $search . '%'),
140
+				'CNT_ISO'  => array('LIKE', '%' . $search . '%'),
141
+			);
142
+		}
143
+
144
+		$where_params = apply_filters(
145
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_where_params',
146
+			$where_params,
147
+			$this->source,
148
+			$this->args
149
+		);
150
+
151
+		$query_args[] = $where_params;
152
+
153
+		/**
154
+		 * Return the $query_args
155
+		 */
156
+		return apply_filters(
157
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_query_args',
158
+			$query_args,
159
+			$this->source,
160
+			$this->args
161
+		);
162
+	}
163
+
164
+
165
+	/**
166
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
167
+	 * friendly keys.
168
+	 *
169
+	 * @param array $where_args
170
+	 * @return array
171
+	 */
172
+	public function sanitizeInputFields(array $where_args): array
173
+	{
174
+		$arg_mapping = [
175
+			'isoIn'  => 'CNT_ISO',
176
+			'in'     => 'CNT_ISO',
177
+			'iso3In' => 'CNT_ISO3',
178
+		];
179
+		return $this->sanitizeWhereArgsForInputFields(
180
+			$where_args,
181
+			$arg_mapping,
182
+			['in']
183
+		);
184
+	}
185 185
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/types/Datetime.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function __construct(EEM_Datetime $datetime_model)
47 47
     {
48
-        $this->setName($this->namespace . 'Datetime');
48
+        $this->setName($this->namespace.'Datetime');
49 49
         $this->setDescription(__('An event date', 'event_espresso'));
50 50
         $this->setIsCustomPostType(false);
51 51
         parent::__construct($datetime_model);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             ),
99 99
             new GraphQLOutputField(
100 100
                 'event',
101
-                $this->namespace . 'Event',
101
+                $this->namespace.'Event',
102 102
                 null,
103 103
                 esc_html__('Event of the datetime.', 'event_espresso')
104 104
             ),
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             ),
207 207
             new GraphQLOutputField(
208 208
                 'status',
209
-                $this->namespace . 'DatetimeStatusEnum',
209
+                $this->namespace.'DatetimeStatusEnum',
210 210
                 'get_active_status',
211 211
                 esc_html__('Datetime status', 'event_espresso')
212 212
             ),
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                 null,
227 227
                 esc_html__('Datetime venue ID', 'event_espresso'),
228 228
                 null,
229
-                function (EE_Datetime $source) {
229
+                function(EE_Datetime $source) {
230 230
                     $venue_ID = $source->venue_ID();
231 231
                     return $venue_ID
232 232
                         // Since venue is a CPT, $type will be 'post'
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
     public function registerMutations(array $inputFields)
321 321
     {
322 322
         register_graphql_input_type(
323
-            'Update' .  $this->name() . 'BaseInput',
323
+            'Update'.$this->name().'BaseInput',
324 324
             [
325 325
                 'fields' => $inputFields,
326 326
             ]
327 327
         );
328 328
         // Register mutation to update an entity.
329 329
         register_graphql_mutation(
330
-            'update' . $this->name(),
330
+            'update'.$this->name(),
331 331
             [
332 332
                 'inputFields'         => $inputFields,
333 333
                 'outputFields'        => [
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
                 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
340 340
             ]
341 341
         );
342
-        $base_input = 'Update' .  $this->name() . 'BaseInput';
342
+        $base_input = 'Update'.$this->name().'BaseInput';
343 343
         // Register mutation to update an entity.
344 344
         register_graphql_mutation(
345
-            'bulkUpdate' . $this->name(),
345
+            'bulkUpdate'.$this->name(),
346 346
             array_merge(
347 347
                 Datetime::bulkUpdateBaseConfig($base_input),
348 348
                 [
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
         // Register mutation to update an entity.
355 355
         register_graphql_mutation(
356
-            'bulkDelete' . $this->namespace . 'Entities',
356
+            'bulkDelete'.$this->namespace.'Entities',
357 357
             [
358 358
                 'inputFields'         => [
359 359
                     'entityIds'  => [
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
                     ],
365 365
                     'entityType' => [
366 366
                         'type'        => [
367
-                            'non_null' => $this->namespace . 'ModelNameEnum',
367
+                            'non_null' => $this->namespace.'ModelNameEnum',
368 368
                         ],
369 369
                         'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
370 370
                     ],
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         );
387 387
         // Register mutation to delete an entity.
388 388
         register_graphql_mutation(
389
-            'delete' . $this->name(),
389
+            'delete'.$this->name(),
390 390
             [
391 391
                 'inputFields'         => [
392 392
                     'id'                => $inputFields['id'],
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
                     lcfirst($this->name()) => [
400 400
                         'type'        => $this->name(),
401 401
                         'description' => esc_html__('The object before it was deleted', 'event_espresso'),
402
-                        'resolve'     => static function ($payload) {
402
+                        'resolve'     => static function($payload) {
403 403
                             $deleted = (object) $payload['deleted'];
404 404
 
405 405
                             return ! empty($deleted) ? $deleted : null;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
         unset($inputFields['id']);
415 415
         // Register mutation to update an entity.
416 416
         register_graphql_mutation(
417
-            'create' . $this->name(),
417
+            'create'.$this->name(),
418 418
             [
419 419
                 'inputFields'         => $inputFields,
420 420
                 'outputFields'        => [
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
         // Register mutation to update an entity.
431 431
         register_graphql_mutation(
432
-            'reorder' . $this->namespace . 'Entities',
432
+            'reorder'.$this->namespace.'Entities',
433 433
             [
434 434
                 'inputFields'         => [
435 435
                     'entityIds'  => [
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                     ],
441 441
                     'entityType' => [
442 442
                         'type'        => [
443
-                            'non_null' => $this->namespace . 'ModelNameEnum',
443
+                            'non_null' => $this->namespace.'ModelNameEnum',
444 444
                         ],
445 445
                         'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
446 446
                     ],
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
                 'outputFields'        => [
449 449
                     'ok' => [
450 450
                         'type'    => 'Boolean',
451
-                        'resolve' => function ($payload) {
451
+                        'resolve' => function($payload) {
452 452
                             return (bool) $payload['ok'];
453 453
                         },
454 454
                     ],
Please login to merge, or discard this patch.
Indentation   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -37,423 +37,423 @@
 block discarded – undo
37 37
  */
38 38
 class Datetime extends TypeBase
39 39
 {
40
-    /**
41
-     * EventDate constructor.
42
-     *
43
-     * @param EEM_Datetime $datetime_model
44
-     */
45
-    public function __construct(EEM_Datetime $datetime_model)
46
-    {
47
-        $this->setName($this->namespace . 'Datetime');
48
-        $this->setDescription(__('An event date', 'event_espresso'));
49
-        $this->setIsCustomPostType(false);
50
-        parent::__construct($datetime_model);
51
-    }
40
+	/**
41
+	 * EventDate constructor.
42
+	 *
43
+	 * @param EEM_Datetime $datetime_model
44
+	 */
45
+	public function __construct(EEM_Datetime $datetime_model)
46
+	{
47
+		$this->setName($this->namespace . 'Datetime');
48
+		$this->setDescription(__('An event date', 'event_espresso'));
49
+		$this->setIsCustomPostType(false);
50
+		parent::__construct($datetime_model);
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @return GraphQLFieldInterface[]
56
-     */
57
-    public function getFields(): array
58
-    {
59
-        $fields = [
60
-            new GraphQLField(
61
-                'id',
62
-                ['non_null' => 'ID'],
63
-                null,
64
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
65
-            ),
66
-            new GraphQLOutputField(
67
-                'dbId',
68
-                ['non_null' => 'Int'],
69
-                'ID',
70
-                esc_html__('The datetime ID.', 'event_espresso')
71
-            ),
72
-            new GraphQLOutputField(
73
-                'cacheId',
74
-                ['non_null' => 'String'],
75
-                null,
76
-                esc_html__('The cache ID of the object.', 'event_espresso')
77
-            ),
78
-            new GraphQLField(
79
-                'capacity',
80
-                'Int',
81
-                'reg_limit',
82
-                esc_html__('Registration Limit for this time', 'event_espresso'),
83
-                [$this, 'parseInfiniteValue']
84
-            ),
85
-            new GraphQLField(
86
-                'description',
87
-                'String',
88
-                'description',
89
-                esc_html__('Description for Datetime', 'event_espresso')
90
-            ),
91
-            new GraphQLField(
92
-                'endDate',
93
-                'String',
94
-                'end_date_and_time',
95
-                esc_html__('End date and time of the Event', 'event_espresso'),
96
-                [$this, 'formatDatetime']
97
-            ),
98
-            new GraphQLOutputField(
99
-                'event',
100
-                $this->namespace . 'Event',
101
-                null,
102
-                esc_html__('Event of the datetime.', 'event_espresso')
103
-            ),
104
-            new GraphQLInputField(
105
-                'event',
106
-                'ID',
107
-                null,
108
-                esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
109
-            ),
110
-            new GraphQLInputField(
111
-                'eventId',
112
-                'Int',
113
-                null,
114
-                esc_html__('Event ID of the datetime.', 'event_espresso')
115
-            ),
116
-            new GraphQLOutputField(
117
-                'isActive',
118
-                'Boolean',
119
-                'is_active',
120
-                esc_html__('Flag indicating datetime is active', 'event_espresso')
121
-            ),
122
-            new GraphQLOutputField(
123
-                'isExpired',
124
-                'Boolean',
125
-                'is_expired',
126
-                esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
127
-            ),
128
-            new GraphQLField(
129
-                'isPrimary',
130
-                'Boolean',
131
-                'is_primary',
132
-                esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
133
-            ),
134
-            new GraphQLOutputField(
135
-                'isSoldOut',
136
-                'Boolean',
137
-                'sold_out',
138
-                esc_html__(
139
-                    'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
140
-                    'event_espresso'
141
-                )
142
-            ),
143
-            new GraphQLField(
144
-                'isTrashed',
145
-                'Boolean',
146
-                null,
147
-                esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'),
148
-                null,
149
-                [$this, 'getIsTrashed']
150
-            ),
151
-            new GraphQLOutputField(
152
-                'isUpcoming',
153
-                'Boolean',
154
-                'is_upcoming',
155
-                esc_html__('Whether the date is upcoming', 'event_espresso')
156
-            ),
157
-            new GraphQLOutputField(
158
-                'length',
159
-                'Int',
160
-                'length',
161
-                esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
162
-            ),
163
-            new GraphQLField(
164
-                'name',
165
-                'String',
166
-                'name',
167
-                esc_html__('Datetime Name', 'event_espresso')
168
-            ),
169
-            new GraphQLField(
170
-                'order',
171
-                'Int',
172
-                'order',
173
-                esc_html__('The order in which the Datetime is displayed', 'event_espresso')
174
-            ),
175
-            new GraphQLOutputField(
176
-                'parent',
177
-                $this->name(),
178
-                null,
179
-                esc_html__('The parent datetime of the current datetime', 'event_espresso')
180
-            ),
181
-            new GraphQLInputField(
182
-                'parent',
183
-                'ID',
184
-                null,
185
-                esc_html__('The parent datetime ID', 'event_espresso')
186
-            ),
187
-            new GraphQLField(
188
-                'reserved',
189
-                'Int',
190
-                'reserved',
191
-                esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
192
-            ),
193
-            new GraphQLField(
194
-                'startDate',
195
-                'String',
196
-                'start_date_and_time',
197
-                esc_html__('Start date and time of the Event', 'event_espresso'),
198
-                [$this, 'formatDatetime']
199
-            ),
200
-            new GraphQLField(
201
-                'sold',
202
-                'Int',
203
-                'sold',
204
-                esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
205
-            ),
206
-            new GraphQLOutputField(
207
-                'status',
208
-                $this->namespace . 'DatetimeStatusEnum',
209
-                'get_active_status',
210
-                esc_html__('Datetime status', 'event_espresso')
211
-            ),
212
-            new GraphQLInputField(
213
-                'tickets',
214
-                ['list_of' => 'ID'],
215
-                null,
216
-                sprintf(
217
-                    '%1$s %2$s',
218
-                    esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
219
-                    esc_html__('Ignored if empty.', 'event_espresso')
220
-                )
221
-            ),
222
-            new GraphQLField(
223
-                'venue',
224
-                'String',
225
-                null,
226
-                esc_html__('Datetime venue ID', 'event_espresso'),
227
-                null,
228
-                function (EE_Datetime $source) {
229
-                    $venue_ID = $source->venue_ID();
230
-                    return $venue_ID
231
-                        // Since venue is a CPT, $type will be 'post'
232
-                        ? Relay::toGlobalId('post', $venue_ID)
233
-                        : null;
234
-                }
235
-            ),
236
-        ];
54
+	/**
55
+	 * @return GraphQLFieldInterface[]
56
+	 */
57
+	public function getFields(): array
58
+	{
59
+		$fields = [
60
+			new GraphQLField(
61
+				'id',
62
+				['non_null' => 'ID'],
63
+				null,
64
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
65
+			),
66
+			new GraphQLOutputField(
67
+				'dbId',
68
+				['non_null' => 'Int'],
69
+				'ID',
70
+				esc_html__('The datetime ID.', 'event_espresso')
71
+			),
72
+			new GraphQLOutputField(
73
+				'cacheId',
74
+				['non_null' => 'String'],
75
+				null,
76
+				esc_html__('The cache ID of the object.', 'event_espresso')
77
+			),
78
+			new GraphQLField(
79
+				'capacity',
80
+				'Int',
81
+				'reg_limit',
82
+				esc_html__('Registration Limit for this time', 'event_espresso'),
83
+				[$this, 'parseInfiniteValue']
84
+			),
85
+			new GraphQLField(
86
+				'description',
87
+				'String',
88
+				'description',
89
+				esc_html__('Description for Datetime', 'event_espresso')
90
+			),
91
+			new GraphQLField(
92
+				'endDate',
93
+				'String',
94
+				'end_date_and_time',
95
+				esc_html__('End date and time of the Event', 'event_espresso'),
96
+				[$this, 'formatDatetime']
97
+			),
98
+			new GraphQLOutputField(
99
+				'event',
100
+				$this->namespace . 'Event',
101
+				null,
102
+				esc_html__('Event of the datetime.', 'event_espresso')
103
+			),
104
+			new GraphQLInputField(
105
+				'event',
106
+				'ID',
107
+				null,
108
+				esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
109
+			),
110
+			new GraphQLInputField(
111
+				'eventId',
112
+				'Int',
113
+				null,
114
+				esc_html__('Event ID of the datetime.', 'event_espresso')
115
+			),
116
+			new GraphQLOutputField(
117
+				'isActive',
118
+				'Boolean',
119
+				'is_active',
120
+				esc_html__('Flag indicating datetime is active', 'event_espresso')
121
+			),
122
+			new GraphQLOutputField(
123
+				'isExpired',
124
+				'Boolean',
125
+				'is_expired',
126
+				esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
127
+			),
128
+			new GraphQLField(
129
+				'isPrimary',
130
+				'Boolean',
131
+				'is_primary',
132
+				esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
133
+			),
134
+			new GraphQLOutputField(
135
+				'isSoldOut',
136
+				'Boolean',
137
+				'sold_out',
138
+				esc_html__(
139
+					'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
140
+					'event_espresso'
141
+				)
142
+			),
143
+			new GraphQLField(
144
+				'isTrashed',
145
+				'Boolean',
146
+				null,
147
+				esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'),
148
+				null,
149
+				[$this, 'getIsTrashed']
150
+			),
151
+			new GraphQLOutputField(
152
+				'isUpcoming',
153
+				'Boolean',
154
+				'is_upcoming',
155
+				esc_html__('Whether the date is upcoming', 'event_espresso')
156
+			),
157
+			new GraphQLOutputField(
158
+				'length',
159
+				'Int',
160
+				'length',
161
+				esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
162
+			),
163
+			new GraphQLField(
164
+				'name',
165
+				'String',
166
+				'name',
167
+				esc_html__('Datetime Name', 'event_espresso')
168
+			),
169
+			new GraphQLField(
170
+				'order',
171
+				'Int',
172
+				'order',
173
+				esc_html__('The order in which the Datetime is displayed', 'event_espresso')
174
+			),
175
+			new GraphQLOutputField(
176
+				'parent',
177
+				$this->name(),
178
+				null,
179
+				esc_html__('The parent datetime of the current datetime', 'event_espresso')
180
+			),
181
+			new GraphQLInputField(
182
+				'parent',
183
+				'ID',
184
+				null,
185
+				esc_html__('The parent datetime ID', 'event_espresso')
186
+			),
187
+			new GraphQLField(
188
+				'reserved',
189
+				'Int',
190
+				'reserved',
191
+				esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
192
+			),
193
+			new GraphQLField(
194
+				'startDate',
195
+				'String',
196
+				'start_date_and_time',
197
+				esc_html__('Start date and time of the Event', 'event_espresso'),
198
+				[$this, 'formatDatetime']
199
+			),
200
+			new GraphQLField(
201
+				'sold',
202
+				'Int',
203
+				'sold',
204
+				esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
205
+			),
206
+			new GraphQLOutputField(
207
+				'status',
208
+				$this->namespace . 'DatetimeStatusEnum',
209
+				'get_active_status',
210
+				esc_html__('Datetime status', 'event_espresso')
211
+			),
212
+			new GraphQLInputField(
213
+				'tickets',
214
+				['list_of' => 'ID'],
215
+				null,
216
+				sprintf(
217
+					'%1$s %2$s',
218
+					esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
219
+					esc_html__('Ignored if empty.', 'event_espresso')
220
+				)
221
+			),
222
+			new GraphQLField(
223
+				'venue',
224
+				'String',
225
+				null,
226
+				esc_html__('Datetime venue ID', 'event_espresso'),
227
+				null,
228
+				function (EE_Datetime $source) {
229
+					$venue_ID = $source->venue_ID();
230
+					return $venue_ID
231
+						// Since venue is a CPT, $type will be 'post'
232
+						? Relay::toGlobalId('post', $venue_ID)
233
+						: null;
234
+				}
235
+			),
236
+		];
237 237
 
238
-        return apply_filters(
239
-            'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields',
240
-            $fields,
241
-            $this->name,
242
-            $this->model
243
-        );
244
-    }
238
+		return apply_filters(
239
+			'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields',
240
+			$fields,
241
+			$this->name,
242
+			$this->model
243
+		);
244
+	}
245 245
 
246 246
 
247
-    /**
248
-     * @param EE_Datetime   $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 bool
253
-     * @throws Exception
254
-     * @throws InvalidArgumentException
255
-     * @throws InvalidDataTypeException
256
-     * @throws InvalidInterfaceException
257
-     * @throws ReflectionException
258
-     * @throws UserError
259
-     * @throws UnexpectedEntityException
260
-     */
261
-    public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info): bool
262
-    {
263
-        return (bool) $source->get('DTT_deleted');
264
-    }
247
+	/**
248
+	 * @param EE_Datetime   $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 bool
253
+	 * @throws Exception
254
+	 * @throws InvalidArgumentException
255
+	 * @throws InvalidDataTypeException
256
+	 * @throws InvalidInterfaceException
257
+	 * @throws ReflectionException
258
+	 * @throws UserError
259
+	 * @throws UnexpectedEntityException
260
+	 */
261
+	public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info): bool
262
+	{
263
+		return (bool) $source->get('DTT_deleted');
264
+	}
265 265
 
266
-    /**
267
-     * Return the base mutation config for bulk update.
268
-     *
269
-     * @param string $base_input
270
-     * @return array
271
-     */
272
-    public static function bulkUpdateBaseConfig(string $base_input): array
273
-    {
274
-        return [
275
-            'inputFields'     => [
276
-                /**
277
-                 * represents the input that is unique for each entity
278
-                 * e.g. dates may be unique for datetimes and tickets
279
-                 */
280
-                'uniqueInputs' => [
281
-                    'type'        => [
282
-                        'non_null' => ['list_of' => $base_input],
283
-                    ],
284
-                    'description' => esc_html__(
285
-                        'List of unique inputs for each entity in bulk update',
286
-                        'event_espresso'
287
-                    ),
288
-                ],
289
-                /**
290
-                 * represents the common input for all entities
291
-                 * e.g. capacity or quantity may be same for all dates/tickets
292
-                 */
293
-                'sharedInput' => [
294
-                    'type'        => $base_input,
295
-                    'description' => esc_html__(
296
-                        'Shared input for all entities in bulk update',
297
-                        'event_espresso'
298
-                    ),
299
-                ],
300
-            ],
301
-            'outputFields'        => [
302
-                'updated' => [
303
-                    'type' => ['list_of' => 'ID'],
304
-                ],
305
-                'failed' => [
306
-                    'type' => ['list_of' => 'ID'],
307
-                ],
308
-            ],
309
-        ];
310
-    }
266
+	/**
267
+	 * Return the base mutation config for bulk update.
268
+	 *
269
+	 * @param string $base_input
270
+	 * @return array
271
+	 */
272
+	public static function bulkUpdateBaseConfig(string $base_input): array
273
+	{
274
+		return [
275
+			'inputFields'     => [
276
+				/**
277
+				 * represents the input that is unique for each entity
278
+				 * e.g. dates may be unique for datetimes and tickets
279
+				 */
280
+				'uniqueInputs' => [
281
+					'type'        => [
282
+						'non_null' => ['list_of' => $base_input],
283
+					],
284
+					'description' => esc_html__(
285
+						'List of unique inputs for each entity in bulk update',
286
+						'event_espresso'
287
+					),
288
+				],
289
+				/**
290
+				 * represents the common input for all entities
291
+				 * e.g. capacity or quantity may be same for all dates/tickets
292
+				 */
293
+				'sharedInput' => [
294
+					'type'        => $base_input,
295
+					'description' => esc_html__(
296
+						'Shared input for all entities in bulk update',
297
+						'event_espresso'
298
+					),
299
+				],
300
+			],
301
+			'outputFields'        => [
302
+				'updated' => [
303
+					'type' => ['list_of' => 'ID'],
304
+				],
305
+				'failed' => [
306
+					'type' => ['list_of' => 'ID'],
307
+				],
308
+			],
309
+		];
310
+	}
311 311
 
312 312
 
313
-    /**
314
-     * @param array $inputFields The mutation input fields.
315
-     * @throws InvalidArgumentException
316
-     * @throws ReflectionException
317
-     * @throws Exception
318
-     */
319
-    public function registerMutations(array $inputFields)
320
-    {
321
-        register_graphql_input_type(
322
-            'Update' .  $this->name() . 'BaseInput',
323
-            [
324
-                'fields' => $inputFields,
325
-            ]
326
-        );
327
-        // Register mutation to update an entity.
328
-        register_graphql_mutation(
329
-            'update' . $this->name(),
330
-            [
331
-                'inputFields'         => $inputFields,
332
-                'outputFields'        => [
333
-                    lcfirst($this->name()) => [
334
-                        'type'    => $this->name(),
335
-                        'resolve' => [$this, 'resolveFromPayload'],
336
-                    ],
337
-                ],
338
-                'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
339
-            ]
340
-        );
341
-        $base_input = 'Update' .  $this->name() . 'BaseInput';
342
-        // Register mutation to update an entity.
343
-        register_graphql_mutation(
344
-            'bulkUpdate' . $this->name(),
345
-            array_merge(
346
-                Datetime::bulkUpdateBaseConfig($base_input),
347
-                [
348
-                    'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this),
349
-                ]
350
-            )
351
-        );
313
+	/**
314
+	 * @param array $inputFields The mutation input fields.
315
+	 * @throws InvalidArgumentException
316
+	 * @throws ReflectionException
317
+	 * @throws Exception
318
+	 */
319
+	public function registerMutations(array $inputFields)
320
+	{
321
+		register_graphql_input_type(
322
+			'Update' .  $this->name() . 'BaseInput',
323
+			[
324
+				'fields' => $inputFields,
325
+			]
326
+		);
327
+		// Register mutation to update an entity.
328
+		register_graphql_mutation(
329
+			'update' . $this->name(),
330
+			[
331
+				'inputFields'         => $inputFields,
332
+				'outputFields'        => [
333
+					lcfirst($this->name()) => [
334
+						'type'    => $this->name(),
335
+						'resolve' => [$this, 'resolveFromPayload'],
336
+					],
337
+				],
338
+				'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
339
+			]
340
+		);
341
+		$base_input = 'Update' .  $this->name() . 'BaseInput';
342
+		// Register mutation to update an entity.
343
+		register_graphql_mutation(
344
+			'bulkUpdate' . $this->name(),
345
+			array_merge(
346
+				Datetime::bulkUpdateBaseConfig($base_input),
347
+				[
348
+					'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this),
349
+				]
350
+			)
351
+		);
352 352
 
353
-        // Register mutation to update an entity.
354
-        register_graphql_mutation(
355
-            'bulkDelete' . $this->namespace . 'Entities',
356
-            [
357
-                'inputFields'         => [
358
-                    'entityIds'  => [
359
-                        'type'        => [
360
-                            'non_null' => ['list_of' => 'ID'],
361
-                        ],
362
-                        'description' => esc_html__('The list of GUIDs of the entities to be deleted.', 'event_espresso'),
363
-                    ],
364
-                    'entityType' => [
365
-                        'type'        => [
366
-                            'non_null' => $this->namespace . 'ModelNameEnum',
367
-                        ],
368
-                        'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
369
-                    ],
370
-                    'deletePermanently' => [
371
-                        'type'        => 'Boolean',
372
-                        'description' => esc_html__('Whether to delete the entities permanently.', 'event_espresso'),
373
-                    ],
374
-                ],
375
-                'outputFields'        => [
376
-                    'deleted' => [
377
-                        'type' => ['list_of' => 'ID'],
378
-                    ],
379
-                    'failed' => [
380
-                        'type' => ['list_of' => 'ID'],
381
-                    ],
382
-                ],
383
-                'mutateAndGetPayload' => BulkEntityDelete::mutateAndGetPayload(),
384
-            ]
385
-        );
386
-        // Register mutation to delete an entity.
387
-        register_graphql_mutation(
388
-            'delete' . $this->name(),
389
-            [
390
-                'inputFields'         => [
391
-                    'id'                => $inputFields['id'],
392
-                    'deletePermanently' => [
393
-                        'type'        => 'Boolean',
394
-                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
395
-                    ],
396
-                ],
397
-                'outputFields'        => [
398
-                    lcfirst($this->name()) => [
399
-                        'type'        => $this->name(),
400
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
401
-                        'resolve'     => static function ($payload) {
402
-                            $deleted = (object) $payload['deleted'];
353
+		// Register mutation to update an entity.
354
+		register_graphql_mutation(
355
+			'bulkDelete' . $this->namespace . 'Entities',
356
+			[
357
+				'inputFields'         => [
358
+					'entityIds'  => [
359
+						'type'        => [
360
+							'non_null' => ['list_of' => 'ID'],
361
+						],
362
+						'description' => esc_html__('The list of GUIDs of the entities to be deleted.', 'event_espresso'),
363
+					],
364
+					'entityType' => [
365
+						'type'        => [
366
+							'non_null' => $this->namespace . 'ModelNameEnum',
367
+						],
368
+						'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
369
+					],
370
+					'deletePermanently' => [
371
+						'type'        => 'Boolean',
372
+						'description' => esc_html__('Whether to delete the entities permanently.', 'event_espresso'),
373
+					],
374
+				],
375
+				'outputFields'        => [
376
+					'deleted' => [
377
+						'type' => ['list_of' => 'ID'],
378
+					],
379
+					'failed' => [
380
+						'type' => ['list_of' => 'ID'],
381
+					],
382
+				],
383
+				'mutateAndGetPayload' => BulkEntityDelete::mutateAndGetPayload(),
384
+			]
385
+		);
386
+		// Register mutation to delete an entity.
387
+		register_graphql_mutation(
388
+			'delete' . $this->name(),
389
+			[
390
+				'inputFields'         => [
391
+					'id'                => $inputFields['id'],
392
+					'deletePermanently' => [
393
+						'type'        => 'Boolean',
394
+						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
395
+					],
396
+				],
397
+				'outputFields'        => [
398
+					lcfirst($this->name()) => [
399
+						'type'        => $this->name(),
400
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
401
+						'resolve'     => static function ($payload) {
402
+							$deleted = (object) $payload['deleted'];
403 403
 
404
-                            return ! empty($deleted) ? $deleted : null;
405
-                        },
406
-                    ],
407
-                ],
408
-                'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
409
-            ]
410
-        );
404
+							return ! empty($deleted) ? $deleted : null;
405
+						},
406
+					],
407
+				],
408
+				'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
409
+			]
410
+		);
411 411
 
412
-        // remove primary key from input.
413
-        unset($inputFields['id']);
414
-        // Register mutation to update an entity.
415
-        register_graphql_mutation(
416
-            'create' . $this->name(),
417
-            [
418
-                'inputFields'         => $inputFields,
419
-                'outputFields'        => [
420
-                    lcfirst($this->name()) => [
421
-                        'type'    => $this->name(),
422
-                        'resolve' => [$this, 'resolveFromPayload'],
423
-                    ],
424
-                ],
425
-                'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
426
-            ]
427
-        );
412
+		// remove primary key from input.
413
+		unset($inputFields['id']);
414
+		// Register mutation to update an entity.
415
+		register_graphql_mutation(
416
+			'create' . $this->name(),
417
+			[
418
+				'inputFields'         => $inputFields,
419
+				'outputFields'        => [
420
+					lcfirst($this->name()) => [
421
+						'type'    => $this->name(),
422
+						'resolve' => [$this, 'resolveFromPayload'],
423
+					],
424
+				],
425
+				'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
426
+			]
427
+		);
428 428
 
429
-        // Register mutation to update an entity.
430
-        register_graphql_mutation(
431
-            'reorder' . $this->namespace . 'Entities',
432
-            [
433
-                'inputFields'         => [
434
-                    'entityIds'  => [
435
-                        'type'        => [
436
-                            'non_null' => ['list_of' => 'ID'],
437
-                        ],
438
-                        'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'),
439
-                    ],
440
-                    'entityType' => [
441
-                        'type'        => [
442
-                            'non_null' => $this->namespace . 'ModelNameEnum',
443
-                        ],
444
-                        'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
445
-                    ],
446
-                ],
447
-                'outputFields'        => [
448
-                    'ok' => [
449
-                        'type'    => 'Boolean',
450
-                        'resolve' => function ($payload) {
451
-                            return (bool) $payload['ok'];
452
-                        },
453
-                    ],
454
-                ],
455
-                'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(),
456
-            ]
457
-        );
458
-    }
429
+		// Register mutation to update an entity.
430
+		register_graphql_mutation(
431
+			'reorder' . $this->namespace . 'Entities',
432
+			[
433
+				'inputFields'         => [
434
+					'entityIds'  => [
435
+						'type'        => [
436
+							'non_null' => ['list_of' => 'ID'],
437
+						],
438
+						'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'),
439
+					],
440
+					'entityType' => [
441
+						'type'        => [
442
+							'non_null' => $this->namespace . 'ModelNameEnum',
443
+						],
444
+						'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
445
+					],
446
+				],
447
+				'outputFields'        => [
448
+					'ok' => [
449
+						'type'    => 'Boolean',
450
+						'resolve' => function ($payload) {
451
+							return (bool) $payload['ok'];
452
+						},
453
+					],
454
+				],
455
+				'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(),
456
+			]
457
+		);
458
+	}
459 459
 }
Please login to merge, or discard this patch.