class SocialUserNameConstraintValidator in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.2 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.3 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.5 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.6 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.7 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 8.8 modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 10.3.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 10.0.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 10.1.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
- 10.2.x modules/social_features/social_user/src/Plugin/Validation/Constraint/SocialUserNameConstraintValidator.php \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
Validates the UserName constraint no email address allowed in the username.
Hierarchy
- class \Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator implements ContainerInjectionInterface
Expanded class hierarchy of SocialUserNameConstraintValidator
1 file declares its use of SocialUserNameConstraintValidator
- SocialUserNameConstraintTest.php in modules/
social_features/ social_user/ tests/ src/ Unit/ Validation/ Constraint/ SocialUserNameConstraintTest.php
1 string reference to 'SocialUserNameConstraintValidator'
- social_user.services.yml in modules/
social_features/ social_user/ social_user.services.yml - modules/social_features/social_user/social_user.services.yml
1 service uses SocialUserNameConstraintValidator
- social_user.username_constraint in modules/
social_features/ social_user/ social_user.services.yml - Drupal\social_user\Plugin\Validation\Constraint\SocialUserNameConstraintValidator
File
- modules/
social_features/ social_user/ src/ Plugin/ Validation/ Constraint/ SocialUserNameConstraintValidator.php, line 15
Namespace
Drupal\social_user\Plugin\Validation\ConstraintView source
class SocialUserNameConstraintValidator extends ConstraintValidator implements ContainerInjectionInterface {
protected $typedDataManager;
/**
* {@inheritdoc}
*/
public function __construct(TypedDataManagerInterface $typed_data_manager) {
$this->typedDataManager = $typed_data_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('typed_data_manager'));
}
/**
* {@inheritdoc}
*/
public function validate($items, Constraint $constraint) {
if (is_null($items)) {
return;
}
if ($nameField = $items
->first()) {
$name = $nameField
->__get('value');
$definition = DataDefinition::create('string')
->setConstraints([
'Email' => [],
]);
$typed_data = $this->typedDataManager
->create($definition, $name);
$violations = $typed_data
->validate();
if (count($violations) == 0) {
$this->context
->addViolation($constraint->usernameIsEmailMessage);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialUserNameConstraintValidator:: |
protected | property | ||
SocialUserNameConstraintValidator:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
SocialUserNameConstraintValidator:: |
public | function | Checks if the passed value is valid. | |
SocialUserNameConstraintValidator:: |
public | function |