Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / Validation / RecursiveContextualValidator.php
index a5d453ae58e5a6b8bf3b879e0bf5ddb7f78f6496..449996710eb60a9fa54d933801b7f2b713e9105d 100644 (file)
@@ -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)) {