DataTransformer
class DataTransformer
Properties
| protected DateTimeZone|null | $dateTimezone | ||
| protected TransformationContext | $defaultContext | ||
| protected TransformationContext | $allContext | ||
| protected TransformationContext | $persistenceContext |
Methods
Create a data transformer.
Get the default root context.
Get the non-transforming root context.
Get the immutable constructable persistence context.
Transform one data object through the fixed metadata path.
Transform the root payload for Hypervel's resource response pipeline.
Transform a nested data object within the current root operation.
Transform a data collection within the current root operation.
Transform a reached data value within the current root operation.
Transform a paginator while retaining its native metadata.
Serialize a paginator clone with replacement items while retaining native metadata.
Get collection items without triggering public transformation behavior.
Apply wrapping and resolved top-level data.
Copy values for metadata proven to need no property transformation.
Transform values through immutable class metadata.
Determine if a lazy property is visible for this transformation.
Transform one visible property value.
Resolve wrapping behavior for a nested transformable value.
Merge a reached data instance's partials into its local context.
Get a custom transformer for a property value.
Get an operation transformer matching a runtime value.
Determine if a transformer key matches a runtime value.
Resolve one transformer once for the current root operation.
Get iterable item metadata accepted by the runtime value.
Transform typed iterable items while preserving supported containers.
Transform one typed iterable item.
Transform one fixed built-in value.
Apply resolved partials to an unchanged nested data value.
Apply resolved partials to unchanged data items in a typed iterable.
Apply only and except selections to a plain array value.
Details
at line 55
__construct(Container $container, DataClassRepository $dataClasses, DataConfig $config)
Create a data transformer.
at line 80
TransformationContext
defaultContext(object $data)
Get the default root context.
Temporary instance partials are consumed when present.
at line 94
TransformationContext
allContext(object $data)
Get the non-transforming root context.
Temporary instance partials are consumed when present.
at line 108
TransformationContext
persistenceContext()
Get the immutable constructable persistence context.
at line 116
array
transform(BaseData|TransformableData|BaseDataCollectable|TransformableData $data, TransformationContext $context)
Transform one data object through the fixed metadata path.
at line 130
array
transformForResourceResponse(BaseData|TransformableData|BaseDataCollectable|TransformableData $data, TransformationContext $context, Collection|null $rootItems = null)
Transform the root payload for Hypervel's resource response pipeline.
at line 154
protected array
transformData(BaseData&TransformableData $data, TransformationContext $context, array $extensions, bool $includeAdditionalData = true)
Transform a nested data object within the current root operation.
at line 256
protected array
transformCollectable(BaseDataCollectable&TransformableData $data, TransformationContext $context, array $extensions, bool $includePaginationData = true, Collection|null $rootItems = null)
Transform a data collection within the current root operation.
at line 310
protected array|BaseData|BaseDataCollectable
transformNested(BaseData|BaseDataCollectable $value, TransformationContext $context, array $extensions)
Transform a reached data value within the current root operation.
at line 332
protected array
transformPaginatorCollectable(PaginatedDataCollection|CursorPaginatedDataCollection $data, array $items)
Transform a paginator while retaining its native metadata.
at line 355
protected array
transformPaginator(AbstractPaginator|AbstractCursorPaginator $paginator, array $items)
Serialize a paginator clone with replacement items while retaining native metadata.
at line 369
protected iterable
collectableItems(BaseDataCollectable $data)
Get collection items without triggering public transformation behavior.
at line 379
protected array
finalizeTransformation(BaseData $data, TransformationContext $context, array $transformed, bool $includeAdditionalData)
Apply wrapping and resolved top-level data.
at line 408
protected array
transformBulkCopy(BaseData $data, DataClass $dataClass)
Copy values for metadata proven to need no property transformation.
at line 428
protected array
transformUsingRecipe(BaseData $data, DataTransformationRecipe $recipe, TransformationContext $context, array $extensions)
Transform values through immutable class metadata.
at line 477
protected bool
includesLazy(Lazy $lazy, DataProperty $property, TransformationContext $context)
Determine if a lazy property is visible for this transformation.
at line 509
protected mixed
transformPropertyValue(DataProperty $property, mixed $value, TransformationContext $context, array $extensions)
Transform one visible property value.
at line 586
protected WrapExecutionType
resolveWrapExecutionType(BaseData|BaseDataCollectable $value, TransformationContext $context)
Resolve wrapping behavior for a nested transformable value.
at line 606
protected TransformationContext
mergeInstancePartials(BaseData|BaseDataCollectable $value, TransformationContext $context)
Merge a reached data instance's partials into its local context.
at line 628
protected Transformer|null
propertyTransformer(DataProperty $property, mixed $value, TransformationContext $context, array $extensions)
Get a custom transformer for a property value.
at line 663
protected Transformer|null
runtimeTransformer(mixed $value, TransformationContext $context, array $extensions)
Get an operation transformer matching a runtime value.
at line 682
protected bool
matchesTransformable(string $transformable, mixed $value)
Determine if a transformer key matches a runtime value.
at line 697
protected Transformer
resolveTransformer(Transformer|string $transformer, array $extensions)
Resolve one transformer once for the current root operation.
at line 714
protected Type|null
iterableTypeForValue(DataProperty $property, mixed $value)
Get iterable item metadata accepted by the runtime value.
at line 730
protected array
transformIterable(DataProperty $property, iterable $items, Type $itemType, TransformationContext $context, array $extensions)
Transform typed iterable items while preserving supported containers.
at line 757
protected mixed
transformIterableItem(DataProperty $property, mixed $value, Type $type, TransformationContext $context, array $extensions)
Transform one typed iterable item.
at line 802
protected mixed
transformBuiltIn(mixed $value)
Transform one fixed built-in value.
at line 827
protected void
propagatePartials(BaseData|BaseDataCollectable $value, TransformationContext $context, string $property)
Apply resolved partials to an unchanged nested data value.
at line 848
protected void
propagateIterablePartials(iterable $items, TransformationContext $context, string $property)
Apply resolved partials to unchanged data items in a typed iterable.
at line 889
protected array
filterArray(array $value, PartialTree|null $only, PartialTree|null $except)
Apply only and except selections to a plain array value.