Skip to content

Commit

Permalink
Docs: raw value tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed May 6, 2023
1 parent 855a5c3 commit af6b580
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ of them to type-safe objects.
- [Object creator](#object-creator)
- [Create without constructor](#create-without-constructor)
- [Metadata validation and preloading](#metadata-validation-and-preloading)
- [Tracking input values](#tracking-input-values)

## Setup

Expand Down Expand Up @@ -1751,3 +1752,28 @@ $metaLoader->preloadFromPaths([
__DIR__ . '/path2',
]);
```

## Tracking input values

Track input values of every mapped object in hierarchy, before they were processed by rules.

> Use only for debugging, because this may be memory intensive
```php
use Orisai\ObjectMapper\Processing\Options;

$initialValues = [];

$options = new Options();
$options->setTrackRawValues(true);
$object = $processor->process($initialValues, TrackedInput::class, $options);

$values = $processor->getRawValues($object); // mixed
$values === $initialValues; // true
```

To make it work,following conditions must be met:

- object was mapped by object mapper (no manually created objects)
- it was mapped in current php process (no serialization)
- option is set to enable raw values tracking

0 comments on commit af6b580

Please sign in to comment.