Oihana PHP System

hydrateDocumentLineItem.php

Table of Contents

Functions

hydrateDocumentLineItem()  : mixed
Hydrate an array definition with the product or service class of a document line item.

Functions

hydrateDocumentLineItem()

Hydrate an array definition with the product or service class of a document line item.

hydrateDocumentLineItem([mixed $init = null ]) : mixed

The item of a BusinessDocumentLine is typed as a Product|Service union, which no property type can resolve on its own : the target class is therefore read from the payload's JSON-LD @type.

  • a @type ending with Service (e.g. Service, FoodService) gives a Service ;
  • anything else gives a Product — the commerce-enriched product of this package, which is a org\schema\Product and so satisfies the line's declared type.

🔑 A bare reference survives inside a list, exactly as it does on its own : a list of unresolved handles comes back as it stands, and only an entry that was an array and resolved to nothing is dropped. The keys stay gap-free — a filtered list left with holes serializes as a JSON object, and a consumer walking the value gets something it cannot walk.

Parameters
$init : mixed = null

Single item data or array of item data.

Tags
throws
HydrationException
ReflectionException
On this page

Search results