TypedDataMetadata.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/TypedData/Validation/TypedDataMetadata.php
  2. 10 core/lib/Drupal/Core/TypedData/Validation/TypedDataMetadata.php
  3. 11.x core/lib/Drupal/Core/TypedData/Validation/TypedDataMetadata.php

Namespace

Drupal\Core\TypedData\Validation

File

core/lib/Drupal/Core/TypedData/Validation/TypedDataMetadata.php

View source
<?php

namespace Drupal\Core\TypedData\Validation;

use Drupal\Core\TypedData\TypedDataInterface;
use Symfony\Component\Validator\Mapping\CascadingStrategy;
use Symfony\Component\Validator\Mapping\MetadataInterface;
use Symfony\Component\Validator\Mapping\TraversalStrategy;

/**
 * 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 findConstraints($group) : array {
        return $this->getConstraints();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getConstraints() : array {
        return $this->typedData
            ->getConstraints();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getTraversalStrategy() : int {
        return TraversalStrategy::NONE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCascadingStrategy() : int {
        // By default, never cascade into validating referenced data structures.
        return CascadingStrategy::NONE;
    }

}

Classes

Title Deprecated Summary
TypedDataMetadata Validator metadata for typed data objects.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.