Class HttpApiV2Controller

Class HttpApiV2Controller

Contains common functionality for all the GX2 APIv2 controllers. You can use the $api instance in the child-controllers in order to gain access to request and response information. The $uri variable is an array that contains the requested resource path.

You can use a protected "__initialize" method in your child controllers for performing common operations without overriding the parent constructor method.

This class contains some private methods that define the core operations of each controller and should not be called from a child-controller (like validation, authorization, rate limiting). The only way to disable the execution of these methods is to override the controller.

AbstractApiV2Controller
HttpApiV2Controller

Direct known subclasses

AbstractImagesApiV2Controller, AddressesApiV2Controller, EmailsApiV2Controller, ManufacturersApiV2Controller, OrdersApiV2Controller, OrdersHistoryApiV2Controller, OrdersItemsApiV2Controller, OrdersItemsAttributesApiV2Controller, OrderStatusesApiV2Controller, OrdersTotalsApiV2Controller, ProductReviewsApiV2Controller, ProductsApiV2Controller, AddressFormatsApiV2Controller, ProductsLinksApiV2Controller, QuantityUnitsApiV2Controller, ReviewsApiV2Controller, ShopInformationApiV2Controller, TaxClassesApiV2Controller, TaxRatesApiV2Controller, TaxZonesApiV2Controller, TrackingCodeApiV2Controller, VpeApiV2Controller, WithdrawalsApiV2Controller, AttachmentsApiV2Controller, ZonesApiV2Controller, CacheApiV2Controller, CategoriesApiV2Controller, CountriesApiV2Controller, CustomerGroupsApiV2Controller, CustomersApiV2Controller, DefaultApiV2Controller

Package: ApiV2Controllers
Category: System
See: AbstractApiV2Controller
Todo:

Add _cacheResponse() helper function which will cache request data and it will provide the required headers.


Located at Controllers/Api/HttpApiV2Controller.inc.php

Methods summary

protected _sortResponse( array & $response )

Sort response array with the "sort" GET parameter.

protected _minimizeResponse( array & $response )

Minimize response using the $fields parameter.

protected _paginateResponse( array & $response, integer $p_totalItemCount = null )

Paginate response using the $page and $per_page GET parameters.

protected _linkResponse( array & $response )

Include links to response resources.

protected _writeResponse( array $response, integer $p_statusCode = 200 )

Write JSON encoded response data.

protected _mapResponse( array $criteria ) : boolean

Map the sub-resource to another controller.

protected _searchResponse( array & $response, string $p_keyword )

Perform a search on the response array.

protected _locateResource( string $p_name, integer $p_id )

Add location header to a specific response.

protected _setJsonValue( string $jsonString, string $property, string $value ) : string

Methods inherited from AbstractApiV2Controller

__construct(), _prepareResponse(), _setRateLimitHeader(), _validateRequest()

Constants summary

Constants inherited from AbstractApiV2Controller

DEFAULT_CONTROLLER_NAME, DEFAULT_PAGE_ITEMS, DEFAULT_RATE_LIMIT, DEFAULT_RATE_RESET_PERIOD

Properties summary

Properties inherited from AbstractApiV2Controller

$api, $uri