-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormTransformerInterface.php
More file actions
45 lines (40 loc) · 1.48 KB
/
Copy pathFormTransformerInterface.php
File metadata and controls
45 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Quatrevieux\Form\Transformer;
use OutOfBoundsException;
use Quatrevieux\Form\DataMapper\DataMapperInterface;
use Quatrevieux\Form\Transformer\Field\FieldTransformerInterface;
/**
* Base type for transform raw HTTP fields to array of data class properties values
*
* This transformer is called juste before {@see DataMapperInterface::toDataObject()} on submit,
* or juste after {@see DataMapperInterface::toArray()} on httpValue normalisation.
*
* The transformer implementation must filter all extra HTTP fields to ensure that undesired properties will not be filled on data object.
*/
interface FormTransformerInterface
{
/**
* Transform raw HTTP value to array of data object properties values
*
* @param mixed[] $value Raw HTTP value
*
* @return TransformationResult Result of transformation process. Contains properties values and transformation errors
*/
public function transformFromHttp(array $value): TransformationResult;
/**
* Transform data object properties values to normalized HTTP fields
*
* @param mixed[] $value Array of properties values
*
* @return mixed[] Normalized HTTP fields value
*/
public function transformToHttp(array $value): array;
/**
* Get the transformer for the given field
*
* @param string $fieldName Field name
*
* @return FieldTransformerInterface
*/
public function fieldTransformer(string $fieldName): FieldTransformerInterface;
}