X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FTypedData%2FValidation%2FRecursiveContextualValidator.php;h=449996710eb60a9fa54d933801b7f2b713e9105d;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=a5d453ae58e5a6b8bf3b879e0bf5ddb7f78f6496;hpb=9424afc6c1f518c301bf87a23c047d1873435d05;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php b/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php index a5d453ae5..449996710 100644 --- a/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php +++ b/web/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php @@ -126,10 +126,16 @@ class RecursiveContextualValidator implements ContextualValidatorInterface { $metadata = $this->metadataFactory->getMetadataFor($data); $cache_key = spl_object_hash($data); $property_path = $is_root_call ? '' : PropertyPath::append($previous_path, $data->getName()); + + // Prefer a specific instance of the typed data manager stored by the data + // if it is available. This is necessary for specialized typed data objects, + // for example those using the typed config subclass of the manager. + $typed_data_manager = method_exists($data, 'getTypedDataManager') ? $data->getTypedDataManager() : $this->typedDataManager; + // Pass the canonical representation of the data as validated value to // constraint validators, such that they do not have to care about Typed // Data. - $value = $this->typedDataManager->getCanonicalRepresentation($data); + $value = $typed_data_manager->getCanonicalRepresentation($data); $this->context->setNode($value, $data, $metadata, $property_path); if (isset($constraints) || !$this->context->isGroupValidated($cache_key, Constraint::DEFAULT_GROUP)) {