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.
Determine whether a data value lies at the maximum depth, throwing when configured to.
Transform a reached data value within the current root operation.
Transform a paginated data collection with its pagination links and metadata.
Transform a paginator into its wrapped items, links, and metadata.
Get the links and metadata describing a paginator's current page.
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.
Ensure every nested partial path starts with a visible property of the data class.
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 the declared iterable type, with item metadata, that receives 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 59
__construct(Container $container, DataClassRepository $dataClasses, DataConfig $config)
Create a data transformer.
at line 86
TransformationContext
defaultContext(object $data)
Get the default root context.
Temporary instance partials are consumed when present.
at line 100
TransformationContext
allContext(object $data)
Get the non-transforming root context.
Temporary instance partials are consumed when present.
at line 114
TransformationContext
persistenceContext()
Get the immutable constructable persistence context.
at line 122
array
transform(BaseData|TransformableData|BaseDataCollectable|TransformableData $data, TransformationContext $context)
Transform one data object through the fixed metadata path.
at line 138
array
transformForResourceResponse(BaseData|TransformableData|BaseDataCollectable|TransformableData $data, TransformationContext $context, Collection|null $rootItems = null)
Transform the root payload for Hypervel's resource response pipeline.
The resource wraps the root and adds its additional and pagination data, so the root leaves them out.
at line 162
protected array
transformData(BaseData&TransformableData $data, TransformationContext $context, array $extensions, bool $resourceRoot = false)
Transform a nested data object within the current root operation.
at line 273
protected array
transformCollectable(BaseDataCollectable&TransformableData $data, TransformationContext $context, array $extensions, bool $resourceRoot = false, Collection|null $rootItems = null)
Transform a data collection within the current root operation.
at line 326
protected bool
reachedMaxDepth(TransformationContext $context)
Determine whether a data value lies at the maximum depth, throwing when configured to.
at line 345
protected array|BaseData|BaseDataCollectable
transformNested(BaseData|BaseDataCollectable $value, TransformationContext $context, array $extensions)
Transform a reached data value within the current root operation.
at line 367
protected array
transformPaginatorCollectable(PaginatedDataCollection|CursorPaginatedDataCollection $data, array $items)
Transform a paginated data collection with its pagination links and metadata.
at line 384
protected array
transformPaginator(AbstractPaginator|AbstractCursorPaginator $paginator, array $items, string|null $wrapKey)
Transform a paginator into its wrapped items, links, and metadata.
at line 401
array
paginationInformation(AbstractPaginator|AbstractCursorPaginator $paginator, array $items)
Get the links and metadata describing a paginator's current page.
at line 454
protected iterable
collectableItems(BaseDataCollectable $data)
Get collection items without triggering public transformation behavior.
at line 467
protected array
finalizeTransformation(BaseData $data, TransformationContext $context, array $transformed, bool $resourceRoot)
Apply wrapping and resolved top-level data.
at line 499
protected array
transformBulkCopy(BaseData $data, DataClass $dataClass)
Copy values for metadata proven to need no property transformation.
at line 519
protected array
transformUsingRecipe(BaseData $data, DataTransformationRecipe $recipe, TransformationContext $context, array $extensions)
Transform values through immutable class metadata.
at line 568
protected bool
includesLazy(Lazy $lazy, DataProperty $property, TransformationContext $context)
Determine if a lazy property is visible for this transformation.
at line 600
protected mixed
transformPropertyValue(DataProperty $property, mixed $value, TransformationContext $context, array $extensions)
Transform one visible property value.
at line 691
protected WrapExecutionType
resolveWrapExecutionType(BaseData|BaseDataCollectable $value, TransformationContext $context)
Resolve wrapping behavior for a nested transformable value.
at line 713
protected void
ensureNestedPartialsExist(DataClass $dataClass, TransformationContext $context)
Ensure every nested partial path starts with a visible property of the data class.
Flat selections of unknown names select nothing, as upstream allows.
at line 738
protected TransformationContext
mergeInstancePartials(BaseData|BaseDataCollectable $value, TransformationContext $context)
Merge a reached data instance's partials into its local context.
at line 760
protected Transformer|null
propertyTransformer(DataProperty $property, mixed $value, TransformationContext $context, array $extensions)
Get a custom transformer for a property value.
at line 795
protected Transformer|null
runtimeTransformer(mixed $value, TransformationContext $context, array $extensions)
Get an operation transformer matching a runtime value.
at line 814
protected bool
matchesTransformable(string $transformable, mixed $value)
Determine if a transformer key matches a runtime value.
at line 829
protected Transformer
resolveTransformer(Transformer|string $transformer, array $extensions)
Resolve one transformer once for the current root operation.
at line 846
protected NamedType|null
iterableTypeForValue(DataProperty $property, mixed $value)
Get the declared iterable type, with item metadata, that receives the runtime value.
at line 864
protected array
transformIterable(DataProperty $property, iterable $items, Type $itemType, TransformationContext $context, array $extensions)
Transform typed iterable items while preserving supported containers.
at line 891
protected mixed
transformIterableItem(DataProperty $property, mixed $value, Type $type, TransformationContext $context, array $extensions)
Transform one typed iterable item.
at line 936
protected mixed
transformBuiltIn(mixed $value)
Transform one fixed built-in value.
at line 961
protected void
propagatePartials(BaseData|BaseDataCollectable $value, TransformationContext $context, string $property)
Apply resolved partials to an unchanged nested data value.
at line 982
protected void
propagateIterablePartials(iterable $items, TransformationContext $context, string $property)
Apply resolved partials to unchanged data items in a typed iterable.
at line 1010
protected array
filterArray(array $value, PartialTree|null $only, PartialTree|null $except)
Apply only and except selections to a plain array value.