RequiredConfigDependenciesConstraint.php

Same filename and directory in other branches
  1. 10 core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/RequiredConfigDependenciesConstraint.php

Namespace

Drupal\Core\Config\Plugin\Validation\Constraint

File

core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/RequiredConfigDependenciesConstraint.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Core\Config\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;

/**
 * Checks that config dependencies contain specific types of entities.
 */
class RequiredConfigDependenciesConstraint extends SymfonyConstraint {
    
    /**
     * The error message.
     *
     * @var string
     */
    public string $message = 'This @entity_type requires a @dependency_type.';
    
    /**
     * The IDs of entity types that need to exist in config dependencies.
     *
     * For example, if an entity requires a filter format in its config
     * dependencies, this should contain `filter_format`.
     *
     * @var string[]
     */
    public array $entityTypes = [];
    
    /**
     * {@inheritdoc}
     */
    public function getRequiredOptions() : array {
        return [
            'entityTypes',
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDefaultOption() : ?string {
        return 'entityTypes';
    }

}

Classes

Title Deprecated Summary
RequiredConfigDependenciesConstraint Checks that config dependencies contain specific types of entities.

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