Skip to main content

GF_REST_Controller

Abstract Rest Controller Class

Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:18

Details

Properties

PropertyTypeDescription
$namespacestringEndpoint namespace.
$rest_basestringRoute base.
$_validate_caps_loggedboolIndicates if the capability validation request has been logged.

Methods

MethodDescription
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

NameTypeDefaultDescription
$requestWP_REST_RequestFull 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

NameTypeDefaultDescription
$entryarrayThe 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

NameTypeDefaultDescription
$valuemixedThe 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

NameTypeDefaultDescription
$entryarrayThe entry to be filtered
$field_idsarrayThe 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

NameTypeDefaultDescription
$entryarrayThe entry array
$form_idnullnullThe 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

NameTypeDefaultDescription
$entryarrayThe 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

NameTypeDefaultDescription
$valuestringString 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

NameTypeDefaultDescription
$wp_errorWP_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

NameTypeDefaultDescription
$messagestring

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

NameTypeDefaultDescription
$capabilitystring | arrayThe required capability.
$requestWP_REST_RequestFull 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

NameTypeDefaultDescription
$currentmixedThe existing item to be modified (e.g. feed).
$changesmixedThe changes to be applied.

Returns

  • mixed

Since: 2.4.24

Source: includes/webapi/v2/includes/controllers/class-gf-rest-controller.php:386