CreationContextFactory
class CreationContextFactory
Properties
| protected ValidationStrategy | $validationStrategy | ||
| protected bool | $mapPropertyNames | ||
| protected bool | $disableMagicalCreation | ||
| protected bool | $useOptionalValues | ||
| protected list<string> | $ignoredMagicalMethods | ||
| protected Cast|Cast>> | $casts | ||
| protected Normalizer>|Normalizer> | $normalizers | ||
| protected Closure> | $prepareDataHooks | ||
| protected Closure> | $beforeValidationHooks | ||
| protected Closure> | $beforeRulesHooks | ||
| protected Closure> | $afterRulesHooks | ||
| protected Closure> | $withValidatorHooks | ||
| protected Closure> | $afterValidationHooks | ||
| protected Closure> | $beforeCreationHooks | ||
| protected Closure> | $afterCreationHooks |
Methods
Create a fresh data construction factory.
Set the validation strategy.
Disable validation.
Validate only Request sources.
Validate every source.
Enable or disable property-name mapping.
Disable or enable property-name mapping.
Disable or enable named creation methods.
Enable or disable named creation methods.
Enable or disable Optional values for missing properties.
Disable or enable Optional values for missing properties.
Ignore named creation methods for this operation.
Merge casts for declared base types.
Build immutable options for one root operation.
Invalidate the immutable Create context after factory customization.
Get validation rules for a payload.
Collect data objects.
Create typed items without whole-collection factory dispatch.
Details
at line 82
__construct(DataCreator $creator, DataConfig $config, string $dataClass, CreationContext|null $createContext = null)
Create a fresh data construction factory.
at line 96
CreationContextFactory
validationStrategy(ValidationStrategy $validationStrategy)
Set the validation strategy.
at line 107
CreationContextFactory
withoutValidation()
Disable validation.
at line 115
CreationContextFactory
onlyValidateRequests()
Validate only Request sources.
at line 125
CreationContextFactory
alwaysValidate()
Validate every source.
at line 133
CreationContextFactory
withPropertyNameMapping(bool $withPropertyNameMapping = true)
Enable or disable property-name mapping.
at line 144
CreationContextFactory
withoutPropertyNameMapping(bool $withoutPropertyNameMapping = true)
Disable or enable property-name mapping.
at line 155
CreationContextFactory
withoutMagicalCreation(bool $withoutMagicalCreation = true)
Disable or enable named creation methods.
at line 166
CreationContextFactory
withMagicalCreation(bool $withMagicalCreation = true)
Enable or disable named creation methods.
at line 180
CreationContextFactory
withOptionalValues(bool $withOptionalValues = true)
Enable or disable Optional values for missing properties.
When disabled, a missing Optional property that also accepts null receives null. One that does not accept null still receives Optional.
at line 191
CreationContextFactory
withoutOptionalValues(bool $withoutOptionalValues = true)
Disable or enable Optional values for missing properties.
at line 202
CreationContextFactory
ignoreMagicalMethod(string ...$methods)
Ignore named creation methods for this operation.
at line 215
CreationContextFactory
withCast(string $castable, Cast|string $cast)
Add a cast for a declared base type.
at line 228
CreationContextFactory
withCastCollection(array $casts)
Merge casts for declared base types.
at line 241
CreationContextFactory
withNormalizers(Normalizer|string ...$normalizers)
Add custom source normalizers.
at line 252
CreationContextFactory
prepareData(Closure $hook)
Add a prepare-data hook.
at line 263
CreationContextFactory
beforeValidation(Closure $hook)
Add a before-validation hook.
at line 274
CreationContextFactory
beforeRules(Closure $hook)
Add a before-rules hook.
at line 285
CreationContextFactory
afterRules(Closure $hook)
Add an after-rules hook.
at line 296
CreationContextFactory
withValidator(Closure $hook)
Add a validator customization hook.
at line 307
CreationContextFactory
afterValidation(Closure $hook)
Add an after-validation hook.
at line 318
CreationContextFactory
beforeCreation(Closure $hook)
Add a before-creation hook.
at line 329
CreationContextFactory
afterCreation(Closure $hook)
Add an after-creation hook.
at line 342
CreationContext
get(CreationMode $mode = CreationMode::Create)
Build immutable options for one root operation.
at line 382
protected void
invalidateCreateContext()
Invalidate the immutable Create context after factory customization.
at line 392
BaseData
from(mixed ...$payloads)
Create a data object.
at line 400
Arrayable|array
validate(Arrayable|array $payload)
Validate a payload without casting or construction.
at line 414
array
getValidationRules(array $payload)
Get validation rules for a payload.
at line 495
array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection
collect(mixed $items, string|null $into = null)
Collect data objects.
Contract-typed sources retain every possible rebuildable runtime shape.
at line 512
Enumerable
collectItems(mixed $items)
| internal |
Create typed items without whole-collection factory dispatch.