Newer
Older
Alex Pott
committed
<?php
/**
* @file
* Contains \Drupal\Core\TypedData\Validation\TypedDataMetadata.
Alex Pott
committed
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
*/
namespace Drupal\Core\TypedData\Validation;
use Drupal\Core\TypedData\TypedDataInterface;
use Symfony\Component\Validator\Exception\BadMethodCallException;
use Symfony\Component\Validator\Mapping\CascadingStrategy;
use Symfony\Component\Validator\Mapping\MetadataInterface;
use Symfony\Component\Validator\Mapping\TraversalStrategy;
use Symfony\Component\Validator\ValidationVisitorInterface;
/**
* Validator metadata for typed data objects.
*
* @see \Drupal\Core\TypedData\Validation\RecursiveValidator::getMetadataFor()
*/
class TypedDataMetadata implements MetadataInterface {
/**
* The typed data object the metadata is about.
*
* @var \Drupal\Core\TypedData\TypedDataInterface
*/
protected $typedData;
/**
* Constructs the object.
*
* @param \Drupal\Core\TypedData\TypedDataInterface $typed_data
* The typed data object the metadata is about.
*/
public function __construct(TypedDataInterface $typed_data) {
$this->typedData = $typed_data;
}
/**
* {@inheritdoc}
*/
public function accept(ValidationVisitorInterface $visitor, $typed_data, $group, $propertyPath) {
throw new BadMethodCallException('Not supported.');
}
/**
* {@inheritdoc}
*/
public function findConstraints($group) {
return $this->getConstraints();
}
/**
* {@inheritdoc}
*/
public function getConstraints() {
return $this->typedData->getConstraints();
}
/**
* {@inheritdoc}
*/
public function getTraversalStrategy() {
return TraversalStrategy::NONE;
}
/**
* {@inheritdoc}
*/
public function getCascadingStrategy() {
// By default, never cascade into validating referenced data structures.
return CascadingStrategy::NONE;
}
}