1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ScayTrase\Api\Cruds\Adaptors\DoctrineOrm; |
4
|
|
|
|
5
|
|
|
use Symfony\Bridge\Doctrine\ManagerRegistry; |
6
|
|
|
use Symfony\Component\PropertyAccess\PropertyAccessorInterface; |
7
|
|
|
|
8
|
|
|
final class AssociationPropertyAccessor implements PropertyAccessorInterface |
9
|
|
|
{ |
10
|
|
|
/** @var PropertyAccessorInterface */ |
11
|
|
|
private $delegate; |
12
|
|
|
/** @var ManagerRegistry */ |
13
|
|
|
private $registry; |
14
|
|
|
/** @var AssociationNormalizer */ |
15
|
|
|
private $normalizer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* AssociationPropertyAccessor constructor. |
19
|
|
|
* |
20
|
|
|
* @param PropertyAccessorInterface $delegate |
21
|
|
|
* @param ManagerRegistry $registry |
22
|
|
|
*/ |
23
|
6 |
|
public function __construct(PropertyAccessorInterface $delegate, ManagerRegistry $registry) |
24
|
|
|
{ |
25
|
6 |
|
$this->delegate = $delegate; |
26
|
6 |
|
$this->registry = $registry; |
27
|
|
|
|
28
|
6 |
|
$this->normalizer = new AssociationNormalizer($this->registry); |
29
|
6 |
|
} |
30
|
|
|
|
31
|
|
|
/** {@inheritdoc} */ |
32
|
|
|
public function setValue(&$objectOrArray, $propertyPath, $value) |
33
|
|
|
{ |
34
|
|
|
$value = $this->normalizer->denormalize($objectOrArray, $propertyPath, $value); |
35
|
|
|
|
36
|
|
|
return $this->delegate->setValue($objectOrArray, $propertyPath, $value); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** {@inheritdoc} */ |
40
|
5 |
|
public function getValue($objectOrArray, $propertyPath) |
41
|
|
|
{ |
42
|
5 |
|
return $this->normalizer->normalize( |
43
|
5 |
|
$this->delegate->getValue($objectOrArray, $propertyPath), |
44
|
5 |
|
$objectOrArray, |
45
|
|
|
$propertyPath |
46
|
5 |
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** {@inheritdoc} */ |
50
|
|
|
public function isWritable($objectOrArray, $propertyPath) |
51
|
|
|
{ |
52
|
|
|
return $this->delegate->isWritable($objectOrArray, $propertyPath); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** {@inheritdoc} */ |
56
|
|
|
public function isReadable($objectOrArray, $propertyPath) |
57
|
|
|
{ |
58
|
|
|
return $this->delegate->isReadable($objectOrArray, $propertyPath); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|