PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 2.8.23.5
Pods – Custom Content Types and Fields v2.8.23.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / REST / V1 / Endpoints / Group.php
pods / src / Pods / REST / V1 / Endpoints Last commit date
Base.php 1 week ago Field.php 1 week ago Field_Slug.php 1 week ago Fields.php 1 week ago Group.php 1 week ago Group_Slug.php 1 week ago Groups.php 1 week ago Pod.php 1 week ago Pod_Slug.php 1 week ago Pods.php 1 week ago Swagger_Documentation.php 1 week ago
Group.php
239 lines
1 <?php
2
3 namespace Pods\REST\V1\Endpoints;
4
5 use Tribe__Documentation__Swagger__Provider_Interface as Swagger_Interface;
6 use Tribe__REST__Endpoints__DELETE_Endpoint_Interface as DELETE_Interface;
7 use Tribe__REST__Endpoints__READ_Endpoint_Interface as READ_Interface;
8 use Tribe__REST__Endpoints__UPDATE_Endpoint_Interface as UPDATE_Interface;
9 use WP_REST_Request;
10
11 class Group extends Base implements READ_Interface, UPDATE_Interface, DELETE_Interface, Swagger_Interface {
12
13 /**
14 * {@inheritdoc}
15 *
16 * @since 2.8.0
17 */
18 public $route = '/groups/%1$d';
19
20 /**
21 * {@inheritdoc}
22 *
23 * @since 2.8.11
24 */
25 public $rest_route = '/groups/(?P<id>\\d+)';
26
27 /**
28 * {@inheritdoc}
29 *
30 * @since 2.8.11
31 */
32 public $rest_doc_route = '/groups/{id}';
33
34 /**
35 * {@inheritdoc}
36 *
37 * @since 2.8.0
38 */
39 public $object = 'group';
40
41 /**
42 * {@inheritdoc}
43 *
44 * @since 2.8.0
45 */
46 public function get_documentation() {
47 $GET_defaults = [
48 'in' => 'query',
49 'default' => '',
50 'type' => 'string',
51 ];
52
53 // @todo Handle get/post/delete
54
55 return [
56 'get' => [
57 'summary' => __( 'Returns a single ticket data.', 'pods' ),
58 'parameters' => $this->swaggerize_args( $this->READ_args(), $GET_defaults ),
59 'responses' => [
60 '200' => [
61 'description' => __( 'Returns the data of the ticket with the specified post ID.', 'pods' ),
62 'content' => [
63 'application/json' => [
64 'schema' => [
65 '$ref' => '#/components/schemas/Ticket',
66 ],
67 ],
68 ],
69 ],
70 '400' => [
71 'description' => __( 'The ticket post ID is invalid.', 'pods' ),
72 'content' => [
73 'application/json' => [
74 'schema' => [
75 'type' => 'object',
76 ],
77 ],
78 ],
79 ],
80 '401' => [
81 'description' => __( 'The ticket with the specified ID is not accessible.', 'pods' ),
82 'content' => [
83 'application/json' => [
84 'schema' => [
85 'type' => 'object',
86 ],
87 ],
88 ],
89 ],
90 '404' => [
91 'description' => __( 'A ticket with the specified ID does not exist.', 'pods' ),
92 'content' => [
93 'application/json' => [
94 'schema' => [
95 'type' => 'object',
96 ],
97 ],
98 ],
99 ],
100 ],
101 ],
102 ];
103 }
104
105 /**
106 * {@inheritdoc}
107 *
108 * @since 2.8.0
109 */
110 public function READ_args() {
111 return [
112 'id' => [
113 'type' => 'integer',
114 'in' => 'path',
115 'description' => __( 'The Group ID.', 'pods' ),
116 'required' => true,
117 'validate_callback' => [ $this->validator, 'is_group_id' ],
118 ],
119 'include_fields' => [
120 'type' => 'boolean',
121 'description' => __( 'Whether to include fields (default: off).', 'pods' ),
122 'default' => false,
123 'cli_boolean' => true,
124 ],
125 ];
126 }
127
128 /**
129 * {@inheritdoc}
130 *
131 * @since 2.8.0
132 */
133 public function get( WP_REST_Request $request ) {
134 return $this->get_by_args( 'id', 'id', $request );
135 }
136
137 /**
138 * Determine whether access to READ is available.
139 *
140 * @since 2.8.0
141 *
142 * @return bool Whether access to READ is available.
143 */
144 public function can_read() {
145 return pods_is_admin( 'pods' );
146 }
147
148 /**
149 * {@inheritdoc}
150 *
151 * @since 2.8.0
152 */
153 public function EDIT_args() {
154 return [
155 'id' => [
156 'type' => 'integer',
157 'in' => 'path',
158 'description' => __( 'The Group ID.', 'pods' ),
159 'required' => true,
160 'validate_callback' => [ $this->validator, 'is_group_id' ],
161 ],
162 'name' => [
163 'type' => 'string',
164 'description' => __( 'The new name of the Group.', 'pods' ),
165 ],
166 'label' => [
167 'type' => 'string',
168 'description' => __( 'The singular label of the Group.', 'pods' ),
169 ],
170 'type' => [
171 'type' => 'string',
172 'description' => __( 'The type of the Group.', 'pods' ),
173 ],
174 'args' => [
175 'required' => false,
176 'description' => __( 'A list of additional options to save to the Group.', 'pods' ),
177 'swagger_type' => 'array',
178 ],
179 ];
180 }
181
182 /**
183 * {@inheritdoc}
184 *
185 * @since 2.8.0
186 */
187 public function update( WP_REST_Request $request ) {
188 if ( ! empty( $request['fields'] ) ) {
189 $request->set_param( 'fields', null );
190 }
191
192 return $this->update_by_args( 'id', 'id', $request );
193 }
194
195 /**
196 * {@inheritdoc}
197 *
198 * @since 2.8.0
199 */
200 public function can_edit() {
201 return pods_is_admin( 'pods' );
202 }
203
204 /**
205 * {@inheritdoc}
206 *
207 * @since 2.8.0
208 */
209 public function DELETE_args() {
210 return [
211 'id' => [
212 'type' => 'integer',
213 'in' => 'path',
214 'description' => __( 'The Group ID.', 'pods' ),
215 'required' => true,
216 'validate_callback' => [ $this->validator, 'is_group_id' ],
217 ],
218 ];
219 }
220
221 /**
222 * {@inheritdoc}
223 *
224 * @since 2.8.0
225 */
226 public function delete( WP_REST_Request $request ) {
227 return $this->delete_by_args( 'id', 'id', $request );
228 }
229
230 /**
231 * {@inheritdoc}
232 *
233 * @since 2.8.0
234 */
235 public function can_delete() {
236 return pods_is_admin( 'pods' );
237 }
238 }
239