class CountryCodeConstraint

Same name in other branches
  1. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountryCodeConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\CountryCodeConstraint

Hierarchy

Expanded class hierarchy of CountryCodeConstraint

1 file declares its use of CountryCodeConstraint
CountryCodeConstraintTest.php in core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/CountryCodeConstraintTest.php

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountryCodeConstraint.php, line 14

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class CountryCodeConstraint implements ContainerFactoryPluginInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) : Choice {
        $countries = $container->get(CountryManagerInterface::class)
            ->getList();
        $configuration['choices'] = array_keys($countries);
        return new Choice($configuration);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
CountryCodeConstraint::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create

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