public function filter_response_by_context( $data, $context ) {

		$schema = $this->get_item_schema();
		foreach ( $data as $key => $value ) {
			if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) {
				continue;
			}

			if ( ! in_array( $context, $schema['properties'][ $key ]['context'], true ) ) {
				unset( $data[ $key ] );
				continue;
			}

			if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
				foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) {
					if ( empty( $details['context'] ) ) {
						continue;
					}
					if ( ! in_array( $context, $details['context'], true ) ) {
						if ( isset( $data[ $key ][ $attribute ] ) ) {
							unset( $data[ $key ][ $attribute ] );
						}
					}
				}
			}
		}

		return $data;
	}
public function filter_response_by_context( $data, $context ) {

		$schema = $this->get_item_schema();
		foreach ( $data as $key => $value ) {
			if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) {
				continue;
			}

			if ( ! in_array( $context, $schema['properties'][ $key ]['context'], true ) ) {
				unset( $data[ $key ] );
				continue;
			}

			if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
				foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) {
					if ( empty( $details['context'] ) ) {
						continue;
					}
					if ( ! in_array( $context, $details['context'], true ) ) {
						if ( isset( $data[ $key ][ $attribute ] ) ) {
							unset( $data[ $key ][ $attribute ] );
						}
					}
				}
			}
		}

		return $data;
	}
public function filter_response_by_context ( $ data , $ context ) { $ schema = $ this -> get_item_schema ( ) ; foreach ( $ data as $ key => $ value ) { if ( empty ( $ schema [ 'properties' ] [ $ key ] ) || empty ( $ schema [ 'properties' ] [ $ key ] [ 'context' ] ) ) { continue ; } if ( ! in_array ( $ context , $ schema [ 'properties' ] [ $ key ] [ 'context' ] , true ) ) { unset ( $ data [ $ key ] ) ; continue ; } if ( 'object' === $ schema [ 'properties' ] [ $ key ] [ 'type' ] && ! empty ( $ schema [ 'properties' ] [ $ key ] [ 'properties' ] ) ) { foreach ( $ schema [ 'properties' ] [ $ key ] [ 'properties' ] as $ attribute => $ details ) { if ( empty ( $ details [ 'context' ] ) ) { continue ; } if ( ! in_array ( $ context , $ details [ 'context' ] , true ) ) { if ( isset ( $ data [ $ key ] [ $ attribute ] ) ) { unset ( $ data [ $ key ] [ $ attribute ] ) ; } } } } } return $ data ; }
Filter a response based on the context defined in the schema.

@param array $data
@param string $context
@return array
Filter a response based on the context defined in the schema .