GF_REST_Controller
Abstract Rest Controller Class
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:18
Details
- Kind:
class - Namespace:
(global) - Extends: WP_REST_Controller
Properties
| Property | Type | Description |
|---|---|---|
$namespace | string | Endpoint namespace. |
$rest_base | string | Route base. |
$_validate_caps_logged | bool | Indicates if the capability validation request has been logged. |
Methods
| Method | Description |
|---|---|
parse_entry_search_params() | Parses the entry search, sort and paging parameters from the request |
maybe_json_encode_list_fields() | JSON encodes list fields in the specified $entry and returns the new $entry |
is_json() | Determines if the specified values is a JSON encoded string |
filter_entry_fields() | Filters an entry, removing fields that aren't in the list of specified $field_ids |
maybe_serialize_list_fields() | Serializes list fields in the specified $entry array. |
maybe_json_encode_applicable_fields() | JSON encodes appropriate fields in the specified $entry array |
maybe_decode_json() | Decodes JSON encoded strings. |
get_error_status() | Returns the http error status |
log_debug() | Writes a message to the log |
current_user_can_any() | Validates that the current user has the specified capability. |
patch_array_recursive() | Recursively patches the given item with the supplied changes (deletions, updates, and additions). |
Method Reference
parse_entry_search_params()
public function parse_entry_search_params( $request )
Parses the entry search, sort and paging parameters from the request
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$request | WP_REST_Request | Full data about the request. |
Returns
array— Returns an associative array with the "search_criteria", "paging" and "sorting" keys appropriately populated.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:57
maybe_json_encode_list_fields()
public function maybe_json_encode_list_fields( $entry )
JSON encodes list fields in the specified $entry and returns the new $entry
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry object |
Returns
array— Returns the $entry array with the list fields json encoded
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:118
is_json()
public static function is_json( $value )
Determines if the specified values is a JSON encoded string
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | mixed | The value to be checked |
Returns
bool— True if the speficied value is JSON encoded. False otherwise
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:148
filter_entry_fields()
public static function filter_entry_fields( $entry, $field_ids )
Filters an entry, removing fields that aren't in the list of specified $field_ids
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry to be filtered | |
$field_ids | array | The field IDs to be kept in the entry |
Returns
array— Returns the entry array, containing only the field_ids specified in the $field_ids array.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:166
maybe_serialize_list_fields()
public function maybe_serialize_list_fields( $entry, $form_id=null )
Serializes list fields in the specified $entry array.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry array | |
$form_id | null | null | The current form id |
Returns
array— Returns the $entry array with all it's list fields serialized.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:257
maybe_json_encode_applicable_fields()
public function maybe_json_encode_applicable_fields( $entry )
JSON encodes appropriate fields in the specified $entry array
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | The entry array. |
Returns
array— Returns the $entry array with all appropriate fields JSON encoded.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:287
maybe_decode_json()
public static function maybe_decode_json( $value )
Decodes JSON encoded strings.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | String to be decoded |
Returns
array|mixed— Returns the decoded JSON array. If the specified $value isn't a JSON encoded string, returns $value.
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:316
get_error_status()
public function get_error_status( $wp_error )
Returns the http error status
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$wp_error | WP_Error |
Returns
int— Returns the http status recored in the specified $wp_error
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:333
log_debug()
public function log_debug( $message )
Writes a message to the log
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$message | string |
Since: 2.4-beta-1
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:351
current_user_can_any()
public function current_user_can_any( $capability, $request )
Validates that the current user has the specified capability.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$capability | string | array | The required capability. | |
$request | WP_REST_Request | Full data about the request. |
Returns
bool
Since: 2.4.11
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:365
patch_array_recursive()
public function patch_array_recursive( $current, $changes )
Recursively patches the given item with the supplied changes (deletions, updates, and additions).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$current | mixed | The existing item to be modified (e.g. feed). | |
$changes | mixed | The changes to be applied. |
Returns
mixed
Since: 2.4.24
Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:386