CoolCMS API

CarrierInterface

Driver contract for carrier pickup points, mirroring {@see \App\UI\Api\System\PaymentGateways\Contracts\PaymentGatewayInterface}.

A driver is identified by self::getScriptName() and registers itself through CarrierRegistry (RobotLoader, no neon); its configuration lives in the database (Shipper::$scriptName and Shipper::$settings).

Table of Contents

Methods

getLabel()  : string
Returns the readable name for the admin select ({@see \App\UI\Api\Eshop\Carriers\CarrierRegistry::getOptions()}).
getScriptName()  : string
Returns the driver identity, the value of `Shipper::$scriptName` (packeta, balikovna, ppl).
getWidgetConfig()  : CarrierWidgetConfig|null
Returns the config for rendering the widget on the front end. `null` means the carrier is not configured (missing API key in `Shipper::$settings`) and the front end then does not offer the pickup button.
manualPickupPoint()  : PickupPoint|null
Builds a point from a manual entry by an admin (six fields of the order edit form, payload `pickupPointManual`). Sanitization and column caps are identical to {@see normalizePickupPoint()}; the default {@see \App\UI\Api\Eshop\Carriers\AbstractCarrier::manualPickupPoint()} is the same for all carriers, so a driver need not override it.
normalizePickupPoint()  : PickupPoint|null
Maps the raw widget payload (exactly what the widget emitted on the front end; three different return mechanisms) to the DTO. `null` means an unrecognized or unusable payload (the required point identifier is missing).
supportsPickup()  : bool
Returns whether this driver supports pickup point selection at all (as opposed to a carrier without pickup support that would be only a future placeholder in the registry).

Methods

getLabel()

Returns the readable name for the admin select ({@see \App\UI\Api\Eshop\Carriers\CarrierRegistry::getOptions()}).

public getLabel() : string
Return values
string

getScriptName()

Returns the driver identity, the value of `Shipper::$scriptName` (packeta, balikovna, ppl).

public getScriptName() : string
Return values
string

getWidgetConfig()

Returns the config for rendering the widget on the front end. `null` means the carrier is not configured (missing API key in `Shipper::$settings`) and the front end then does not offer the pickup button.

public getWidgetConfig(Shipper $shipper, array{lang?: string, currency?: string, country?: string, weight?: float} $context) : CarrierWidgetConfig|null

Never exposes the raw Shipper::$settings, only the values the widget needs (a public widget key, no secret).

IMPORTANT: the parameter is the shared ancestor of the carrier entity (Core\Base\Shared), not the Api leaf, because the admin order edit form needs the same config and works with its own leaf App\UI\Admin\Eshop\Models\Entities\Shipper. A driver reads the carrier only through getSetting(), which lives on the shared ancestor.

Parameters
$shipper : Shipper
$context : array{lang?: string, currency?: string, country?: string, weight?: float}

customer language, currency and country plus cart weight (checkout step 2)

Return values
CarrierWidgetConfig|null

manualPickupPoint()

Builds a point from a manual entry by an admin (six fields of the order edit form, payload `pickupPointManual`). Sanitization and column caps are identical to {@see normalizePickupPoint()}; the default {@see \App\UI\Api\Eshop\Carriers\AbstractCarrier::manualPickupPoint()} is the same for all carriers, so a driver need not override it.

public manualPickupPoint(array{code?: mixed, name?: mixed, street?: mixed, city?: mixed, zip?: mixed, country?: mixed} $fields) : PickupPoint|null

null means code or name is missing after sanitization (the point is unusable). A carrier without a driver is handled by ManualPickupPointFactory (snapshot carrier manual) and never reaches this method.

Parameters
$fields : array{code?: mixed, name?: mixed, street?: mixed, city?: mixed, zip?: mixed, country?: mixed}
Return values
PickupPoint|null

normalizePickupPoint()

Maps the raw widget payload (exactly what the widget emitted on the front end; three different return mechanisms) to the DTO. `null` means an unrecognized or unusable payload (the required point identifier is missing).

public normalizePickupPoint(array<string, mixed> $raw) : PickupPoint|null

Sanitization is up to the implementation; no field may pass unsanitized. Nothing is verified against the carrier feed.

Parameters
$raw : array<string, mixed>
Return values
PickupPoint|null

supportsPickup()

Returns whether this driver supports pickup point selection at all (as opposed to a carrier without pickup support that would be only a future placeholder in the registry).

public supportsPickup() : bool
Return values
bool
On this page

Search results