Implements MetadataFactoryInterface::getMetadataFor().
\Drupal\Core\TypedData\TypedDataInterface $typed_data: Some typed data object containing the value to validate.
$name: (optional) The name of the property to get metadata for. Leave empty, if the data is the root of the typed data tree.
Overrides MetadataFactoryInterface::getMetadataFor
public function getMetadataFor($typed_data, $name = '') {
if (!$typed_data instanceof TypedDataInterface) {
throw new \InvalidArgumentException('The passed value must be a typed data object.');
}
$is_container = $typed_data instanceof ComplexDataInterface || $typed_data instanceof ListInterface;
$class = '\\Drupal\\Core\\TypedData\\Validation\\' . ($is_container ? 'PropertyContainerMetadata' : 'Metadata');
return new $class($typed_data, $name, $this);
}