ConstraintFactory.php in Drupal 10
File
core/lib/Drupal/Core/Validation/ConstraintFactory.php
View source
<?php
namespace Drupal\Core\Validation;
use Drupal\Core\Plugin\Factory\ContainerFactory;
use Symfony\Component\Validator\Constraint;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
class ConstraintFactory extends ContainerFactory {
public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery
->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
if (is_subclass_of($plugin_class, ContainerFactoryPluginInterface::class)) {
return $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition);
}
if (is_subclass_of($plugin_class, Constraint::class)) {
return new $plugin_class($configuration);
}
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
}
}