PickupPointSanitizerTrait
Sanitization and length caps for the `cms_mod_eshop_order_shippers.pickup_*` columns.
Shared by AbstractCarrier and ManualPickupPointFactory, which needs the same code for an admin's manual entry for a carrier without a driver (no AbstractCarrier instance exists there).
IMPORTANT: this is a trait, not a service. It must not be registered in DI or appear in
CarrierRegistry; the registry collects findByType(CarrierInterface::class), so
anything implementing the driver interface would show up in the admin carrier select.
Table of Contents
Constants
- MAX_LENGTH_CITY : mixed = 100
- MAX_LENGTH_CODE : mixed = 64
- Length caps of the `cms_mod_eshop_order_shippers.pickup_*` columns.
- MAX_LENGTH_COUNTRY : mixed = 60
- MAX_LENGTH_NAME : mixed = 255
- MAX_LENGTH_RAW : mixed = 8000
- Cap for `pickup_point_data` (text); a cheap safeguard, nothing reads the column yet.
- MAX_LENGTH_STREET : mixed = 100
- MAX_LENGTH_ZIP : mixed = 10
Methods
- buildManualPickupPoint() : PickupPoint|null
- Builds a point from a manual entry by an admin (order edit form).
- buildPickupPoint() : PickupPoint|null
- Builds a sanitized {@see PickupPoint} from values a driver extracted from its widget payload. Returns `null` when the required `code` or `name` is empty after sanitization, since the point is unusable for an order without them.
- sanitizeRaw() : string
- Returns the raw payload as a capped JSON string (`pickup_point_data` is text; nothing reads it yet, it is a safeguard for later shipment creation).
- sanitizeText() : string
- Strips tags (XSS from user text, widget data comes from foreign JS), collapses repeated whitespace and truncates to the length of the matching database column.
Constants
MAX_LENGTH_CITY
private
mixed
MAX_LENGTH_CITY
= 100
MAX_LENGTH_CODE
Length caps of the `cms_mod_eshop_order_shippers.pickup_*` columns.
private
mixed
MAX_LENGTH_CODE
= 64
MAX_LENGTH_COUNTRY
private
mixed
MAX_LENGTH_COUNTRY
= 60
MAX_LENGTH_NAME
private
mixed
MAX_LENGTH_NAME
= 255
MAX_LENGTH_RAW
Cap for `pickup_point_data` (text); a cheap safeguard, nothing reads the column yet.
private
mixed
MAX_LENGTH_RAW
= 8000
MAX_LENGTH_STREET
private
mixed
MAX_LENGTH_STREET
= 100
MAX_LENGTH_ZIP
private
mixed
MAX_LENGTH_ZIP
= 10
Methods
buildManualPickupPoint()
Builds a point from a manual entry by an admin (order edit form).
protected
buildManualPickupPoint(string $carrier, array{code?: mixed, name?: mixed, street?: mixed, city?: mixed, zip?: mixed, country?: mixed} $fields) : PickupPoint|null
Same sanitization and caps as buildPickupPoint() (single source of truth), but
the input is six form text fields; raw is the JSON of the sanitized fields so that
pickup_point_data keeps a readable origin. Returns null when code or name is
missing (both required).
Parameters
- $carrier : string
- $fields : array{code?: mixed, name?: mixed, street?: mixed, city?: mixed, zip?: mixed, country?: mixed}
Return values
PickupPoint|nullbuildPickupPoint()
Builds a sanitized {@see PickupPoint} from values a driver extracted from its widget payload. Returns `null` when the required `code` or `name` is empty after sanitization, since the point is unusable for an order without them.
protected
buildPickupPoint(string $carrier, string|null $code, string|null $name, string|null $street, string|null $city, string|null $zip, string|null $country, array<string, mixed> $raw) : PickupPoint|null
Sanitization: strip_tags, whitespace normalization, truncation to the column length.
Nothing is verified against the carrier feed.
Parameters
- $carrier : string
- $code : string|null
- $name : string|null
- $street : string|null
- $city : string|null
- $zip : string|null
- $country : string|null
- $raw : array<string, mixed>
-
raw widget payload, stored as truncated JSON
Return values
PickupPoint|nullsanitizeRaw()
Returns the raw payload as a capped JSON string (`pickup_point_data` is text; nothing reads it yet, it is a safeguard for later shipment creation).
protected
sanitizeRaw(array<string, mixed> $raw) : string
Parameters
- $raw : array<string, mixed>
Return values
stringsanitizeText()
Strips tags (XSS from user text, widget data comes from foreign JS), collapses repeated whitespace and truncates to the length of the matching database column.
protected
sanitizeText(mixed $value, int $maxLength) : string
Parameters
- $value : mixed
- $maxLength : int