Typed data implementation of the validator MetadataInterface.
Expanded class hierarchy of PropertyContainerMetadata
class PropertyContainerMetadata extends Metadata implements PropertyMetadataContainerInterface {
/**
* Overrides Metadata::accept().
*/
public function accept(ValidationVisitorInterface $visitor, $typed_data, $group, $propertyPath) {
// To let all constraints properly handle empty structures, pass on NULL
// if the data structure is empty. That way existing NotNull or NotBlank
// constraints work as expected.
if ($typed_data
->isEmpty()) {
$typed_data = NULL;
}
$visitor
->visit($this, $typed_data, $group, $propertyPath);
$pathPrefix = empty($propertyPath) ? '' : $propertyPath . '.';
if ($typed_data) {
foreach ($typed_data as $name => $data) {
$metadata = $this->factory
->getMetadataFor($data, $name);
$metadata
->accept($visitor, $data, $group, $pathPrefix . $name);
}
}
}
/**
* Implements PropertyMetadataContainerInterface::hasPropertyMetadata().
*/
public function hasPropertyMetadata($property_name) {
try {
$exists = (bool) $this
->getPropertyMetadata($property_name);
} catch (\LogicException $e) {
$exists = FALSE;
}
return $exists;
}
/**
* Implements PropertyMetadataContainerInterface::getPropertyMetadata().
*/
public function getPropertyMetadata($property_name) {
if ($this->typedData instanceof ListInterface) {
return array(
new Metadata($this->typedData[$property_name], $property_name),
);
}
elseif ($this->typedData instanceof ComplexDataInterface) {
return array(
new Metadata($this->typedData
->get($property_name), $property_name),
);
}
else {
throw new \LogicException("There are no known properties.");
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Metadata:: |
protected | property | The metadata factory used. | |
Metadata:: |
protected | property | The name of the property, or empty if this is the root. | |
Metadata:: |
protected | property | The typed data object the metadata is about. | |
Metadata:: |
public | function |
Implements MetadataInterface::findConstraints(). Overrides MetadataInterface:: |
|
Metadata:: |
public | function |
Returns the name of the property. Overrides PropertyMetadataInterface:: |
|
Metadata:: |
public | function |
Extracts the value of the property from the given container. Overrides PropertyMetadataInterface:: |
|
Metadata:: |
public | function | Constructs the object. | |
PropertyContainerMetadata:: |
public | function |
Overrides Metadata::accept(). Overrides Metadata:: |
|
PropertyContainerMetadata:: |
public | function |
Implements PropertyMetadataContainerInterface::getPropertyMetadata(). Overrides PropertyMetadataContainerInterface:: |
|
PropertyContainerMetadata:: |
public | function |
Implements PropertyMetadataContainerInterface::hasPropertyMetadata(). Overrides PropertyMetadataContainerInterface:: |