ShipcloudController
extends AdminHttpViewController
in package
Class ShipcloudController
Table of Contents
- MAX_DESCRIPTION_LENGTH = 50
- $assets : AssetCollectionInterface
- $contentView : ContentViewInterface
- $httpContextReader : HttpContextReaderInterface
- $httpResponseProcessor : HttpResponseProcessorInterface
- $postDataArray : array<string|int, mixed>
- $queryParametersArray : array<string|int, mixed>
- $serverDataArray : array<string|int, mixed>
- $shipcloudConfigurationStorage : ShipcloudConfigurationStorage
- configuration storage
- $shipcloudLogger : ShipcloudLogger
- logger
- $shipcloudText : ShipcloudText
- wrapper for text phrases
- $db : CI_DB_query_builder
- Query Builder
- __construct() : mixed
- actionCreateLabelForm() : HttpControllerResponse
- Shows a form for entering data for a label
- actionCreateLabelFormSubmit() : JsonHttpControllerResponse
- Processes form submit for forms created by actionCreateLabelForm()
- actionCreateMultiLabelForm() : HttpControllerResponse
- Shows form for bulk label retrieval
- actionCreateMultiLabelFormSubmit() : JsonHttpControllerResponse
- Processes form data from form returned by actionCreateMultiLabelForm().
- actionDefault() : mixed
- Run the actionDefault method.
- actionDeleteShipment() : mixed
- Deletes a shipment label
- actionGetMultiShipmentQuote() : JsonHttpControllerResponse
- Retrieves shipment quotes (bulk retrieval)
- actionGetShipmentQuote() : JsonHttpControllerResponse
- Uses form data (cf. actionCreateLabelForm()) to retrieve a shipment quote
- actionLoadLabelList() : HttpControllerResponse
- Outputs a list of labels for an order identified by its orders_id via the corresponding GET parameter
- actionLoadMultiLabelList() : HttpControllerResponse
- Retrieves list of labels for a set of orders listed in POST[orders_ids].
- actionPickupShipments() : JsonHttpControllerResponse
- Requests pickups for a given list of shipments from each of the carriers involved
- actionUnconfiguredNote() : HttpControllerResponse
- Returns message to be displayed to users if the Shipcloud interface is still unconfigured
- proceed() : mixed
- Override "proceed" method of parent and use it for initialization.
- validateCurrentAdminStatus() : mixed
- Makes sure that the admin status is currently given in session
- _callActionMethod() : HttpControllerResponseInterface
- Invokes an action method by the given action name.
- _enforceLengthLimits() : array<string|int, mixed>
- modifies an array containing a delivery address to suit carrier-specific field lengths
- _getPostData() : string|null
- Returns the expected $_POST value by the given key name.
- _getPostDataCollection() : KeyValueCollection
- Creates and returns a key value collection which represent the global $_POST array.
- _getQueryParameter() : mixed|null
- Returns the expected $_GET value by the given key name.
- _getQueryParametersCollection() : KeyValueCollection
- Creates and returns a key value collection which represent the global $_GET array.
- _getServerData() : string|null
- Returns the expected $_SERVER value by the given key name.
- _getShippingWeight() : mixed
- computes total weight of products for an order
- _prepareSingleFormDataForShipmentRequest() : KeyValueCollection
- Uses POST data from the form returned by actionCreateLabelForm() to populate a KeyValueCollection to be fed to the ShipmentFactory
- _render() : string
- Renders and returns a template file.
- _validatePageToken() : mixed
- Check if the $_POST['pageToken'] or $_GET['pageToken'] variable is provided and if it's valid.
- getDeclaredValue() : float
- retrieves an order's total
- getOrderLanguageCode() : string
- Looks up the language for a given order and returns the 2-letter ISO code
- getTemplateFile() : ExistingFile
- Searches the GXModules directory and admin/html directory for a template file, wich can be useed inside the AdminLayoutHttpControllerResponse object for the template parameter.
- getTransportConditions() : mixed
- isConfigured() : mixed
- determines if Shipcloud is configured and ready to use
- isValidJson() : bool
- isValidRequestMethod() : bool
- makeProductName() : mixed
- prepareJsonInput() : array<string|int, mixed>
- shortenString() : string
- shortens a string to a maximum length, appending “…” if shortening required
- splitStreet() : array<string|int, mixed>
- Heuristically splits up a street address into its component street name and house number
Constants
MAX_DESCRIPTION_LENGTH
public
mixed
MAX_DESCRIPTION_LENGTH
= 50
Properties
$assets
protected
AssetCollectionInterface
$assets
$contentView
protected
ContentViewInterface
$contentView
$httpContextReader
protected
HttpContextReaderInterface
$httpContextReader
$httpResponseProcessor
protected
HttpResponseProcessorInterface
$httpResponseProcessor
$postDataArray
protected
array<string|int, mixed>
$postDataArray
$queryParametersArray
protected
array<string|int, mixed>
$queryParametersArray
$serverDataArray
protected
array<string|int, mixed>
$serverDataArray
$shipcloudConfigurationStorage
configuration storage
protected
ShipcloudConfigurationStorage
$shipcloudConfigurationStorage
$shipcloudLogger
logger
protected
ShipcloudLogger
$shipcloudLogger
$shipcloudText
wrapper for text phrases
protected
ShipcloudText
$shipcloudText
$db
Query Builder
private
CI_DB_query_builder
$db
Methods
__construct()
public
__construct(HttpContextReaderInterface $httpContextReader, HttpResponseProcessorInterface $httpResponseProcessor, ContentViewInterface $contentView) : mixed
Parameters
- $httpContextReader : HttpContextReaderInterface
- $httpResponseProcessor : HttpResponseProcessorInterface
- $contentView : ContentViewInterface
Return values
mixed —actionCreateLabelForm()
Shows a form for entering data for a label
public
actionCreateLabelForm() : HttpControllerResponse
Return values
HttpControllerResponse —actionCreateLabelFormSubmit()
Processes form submit for forms created by actionCreateLabelForm()
public
actionCreateLabelFormSubmit() : JsonHttpControllerResponse
Return values
JsonHttpControllerResponse —actionCreateMultiLabelForm()
Shows form for bulk label retrieval
public
actionCreateMultiLabelForm() : HttpControllerResponse
Return values
HttpControllerResponse —actionCreateMultiLabelFormSubmit()
Processes form data from form returned by actionCreateMultiLabelForm().
public
actionCreateMultiLabelFormSubmit() : JsonHttpControllerResponse
Return values
JsonHttpControllerResponse —actionDefault()
Run the actionDefault method.
public
actionDefault() : mixed
Return values
mixed —actionDeleteShipment()
Deletes a shipment label
public
actionDeleteShipment() : mixed
Return values
mixed —actionGetMultiShipmentQuote()
Retrieves shipment quotes (bulk retrieval)
public
actionGetMultiShipmentQuote() : JsonHttpControllerResponse
Return values
JsonHttpControllerResponse —actionGetShipmentQuote()
Uses form data (cf. actionCreateLabelForm()) to retrieve a shipment quote
public
actionGetShipmentQuote() : JsonHttpControllerResponse
Return values
JsonHttpControllerResponse —actionLoadLabelList()
Outputs a list of labels for an order identified by its orders_id via the corresponding GET parameter
public
actionLoadLabelList() : HttpControllerResponse
Return values
HttpControllerResponse —actionLoadMultiLabelList()
Retrieves list of labels for a set of orders listed in POST[orders_ids].
public
actionLoadMultiLabelList() : HttpControllerResponse
Return values
HttpControllerResponse —actionPickupShipments()
Requests pickups for a given list of shipments from each of the carriers involved
public
actionPickupShipments() : JsonHttpControllerResponse
Return values
JsonHttpControllerResponse —actionUnconfiguredNote()
Returns message to be displayed to users if the Shipcloud interface is still unconfigured
public
actionUnconfiguredNote() : HttpControllerResponse
Return values
HttpControllerResponse —proceed()
Override "proceed" method of parent and use it for initialization.
public
proceed(HttpContextInterface $httpContext) : mixed
This method must call the parent "proceed" in order to work properly.
Parameters
- $httpContext : HttpContextInterface
Return values
mixed —validateCurrentAdminStatus()
Makes sure that the admin status is currently given in session
public
validateCurrentAdminStatus() : mixed
Tags
Return values
mixed —_callActionMethod()
Invokes an action method by the given action name.
protected
_callActionMethod(string $actionName) : HttpControllerResponseInterface
Parameters
- $actionName : string
-
Name of action method to call, without 'action'-Suffix.
Tags
Return values
HttpControllerResponseInterface —Response message.
_enforceLengthLimits()
modifies an array containing a delivery address to suit carrier-specific field lengths
protected
_enforceLengthLimits(string $carrier, array<string|int, mixed> $toArray) : array<string|int, mixed>
Currently returns $toArray unchanged. Future operation tbd.
Parameters
- $carrier : string
- $toArray : array<string|int, mixed>
-
delivery address
Return values
array<string|int, mixed> —_getPostData()
Returns the expected $_POST value by the given key name.
protected
_getPostData(string $keyName) : string|null
This method is the object oriented layer for $_POST[$keyName].
Parameters
- $keyName : string
-
Expected key of post parameter.
Return values
string|null —Either the expected value or null, of not found.
_getPostDataCollection()
Creates and returns a key value collection which represent the global $_POST array.
protected
_getPostDataCollection() : KeyValueCollection
Return values
KeyValueCollection —_getQueryParameter()
Returns the expected $_GET value by the given key name.
protected
_getQueryParameter(string $keyName) : mixed|null
This method is the object oriented layer for $_GET[$keyName].
Parameters
- $keyName : string
-
Expected key of query parameter.
Return values
mixed|null —Either the expected value or null, of not found.
_getQueryParametersCollection()
Creates and returns a key value collection which represent the global $_GET array.
protected
_getQueryParametersCollection() : KeyValueCollection
Return values
KeyValueCollection —_getServerData()
Returns the expected $_SERVER value by the given key name.
protected
_getServerData(string $keyName) : string|null
This method is the object oriented layer for $_SERVER[$keyName].
Parameters
- $keyName : string
-
Expected key of server parameter.
Return values
string|null —Either the expected value or null, of not found.
_getShippingWeight()
computes total weight of products for an order
protected
_getShippingWeight(mixed $orders_id) : mixed
Parameters
- $orders_id : mixed
Return values
mixed —_prepareSingleFormDataForShipmentRequest()
Uses POST data from the form returned by actionCreateLabelForm() to populate a KeyValueCollection to be fed to the ShipmentFactory
protected
_prepareSingleFormDataForShipmentRequest(array<string|int, mixed> $postDataArray[, bool $anon_from = false ][, string $language_code = null ]) : KeyValueCollection
Parameters
- $postDataArray : array<string|int, mixed>
- $anon_from : bool = false
-
used for shipment quote requests
- $language_code : string = null
-
ISO2 language code used for advance notices (e.g. DPD Predict)
Return values
KeyValueCollection —_render()
Renders and returns a template file.
protected
_render(string $templateFile, array<string|int, mixed> $contentArray) : string
Parameters
- $templateFile : string
-
Template file to render.
- $contentArray : array<string|int, mixed>
-
Content array which represent the variables of the template.
Return values
string —Rendered template.
_validatePageToken()
Check if the $_POST['pageToken'] or $_GET['pageToken'] variable is provided and if it's valid.
protected
_validatePageToken([string $customExceptionMessage = null ]) : mixed
Example: public function proceed(HttpContextInterface $httpContext) { parent::proceed($httpContext); // proceed http context from parent class if($_SERVER['REQUEST_METHOD'] === 'POST') { $this->_validatePageToken(); // CSRF Protection } }
Parameters
- $customExceptionMessage : string = null
-
(optional) You can specify a custom exception message.
Tags
Return values
mixed —getDeclaredValue()
retrieves an order's total
protected
getDeclaredValue(int $orders_id) : float
Parameters
- $orders_id : int
-
the order's id
Tags
Return values
float —getOrderLanguageCode()
Looks up the language for a given order and returns the 2-letter ISO code
protected
getOrderLanguageCode(int $orders_id) : string
Parameters
- $orders_id : int
Return values
string —ISO2 language code
getTemplateFile()
Searches the GXModules directory and admin/html directory for a template file, wich can be useed inside the AdminLayoutHttpControllerResponse object for the template parameter.
protected
getTemplateFile(string $templateFile) : ExistingFile
Parameters
- $templateFile : string
-
The relative path and filename to search for
Tags
Return values
ExistingFile —containing absolute file path to the given template file
getTransportConditions()
protected
getTransportConditions(mixed $orderId) : mixed
Parameters
- $orderId : mixed
Return values
mixed —isConfigured()
determines if Shipcloud is configured and ready to use
protected
isConfigured() : mixed
Return values
mixed —isValidJson()
protected
isValidJson(string $string) : bool
Parameters
- $string : string
Return values
bool —isValidRequestMethod()
protected
isValidRequestMethod(string $method) : bool
Parameters
- $method : string
Return values
bool —makeProductName()
protected
makeProductName(mixed $product) : mixed
Parameters
- $product : mixed
Return values
mixed —prepareJsonInput()
protected
prepareJsonInput(string $json) : array<string|int, mixed>
Parameters
- $json : string
Return values
array<string|int, mixed> —shortenString()
shortens a string to a maximum length, appending “…” if shortening required
protected
shortenString(string $subject, int $maxLength) : string
Parameters
- $subject : string
-
string to be shortened
- $maxLength : int
-
maximum length
Return values
string —shortened string
splitStreet()
Heuristically splits up a street address into its component street name and house number
protected
splitStreet(mixed $street_address) : array<string|int, mixed>
Parameters
- $street_address : mixed
Return values
array<string|int, mixed> —with keys 'street' and 'house_no'