class OwnOrAdminConstraint in Simple OAuth (OAuth2) & OpenID Connect 8
Class OwnOrAdminConstraint.
@package Drupal\simple_oauth\Plugin\Validation\Constraint
Plugin annotation
@Constraint(
id = "OwnOrAdmin",
label = @Translation("Own or admin", context = "Validation")
)
Hierarchy
- class \Drupal\simple_oauth\Plugin\Validation\Constraint\OwnOrAdminConstraint extends \Symfony\Component\Validator\Constraint implements OwnOrAdminConstraintInterface
Expanded class hierarchy of OwnOrAdminConstraint
1 file declares its use of OwnOrAdminConstraint
- OwnOrAdminConstraintValidatorTest.php in tests/
src/ Unit/ Plugin/ Validation/ Constraint/ OwnOrAdminConstraintValidatorTest.php
File
- src/
Plugin/ Validation/ Constraint/ OwnOrAdminConstraint.php, line 17
Namespace
Drupal\simple_oauth\Plugin\Validation\ConstraintView source
class OwnOrAdminConstraint extends Constraint implements OwnOrAdminConstraintInterface {
/**
* The current user uid.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* The current user uid.
*
* @var string
*/
protected $permission;
public $message = 'Only users with permission @permission can set this field to other users.';
/**
* {@inheritdoc}
*/
public function getPermission() {
return $this->permission;
}
/**
* {@inheritdoc}
*/
public function getAccount() {
return $this->account ?: \Drupal::currentUser();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OwnOrAdminConstraint:: |
protected | property | The current user uid. | |
OwnOrAdminConstraint:: |
public | property | ||
OwnOrAdminConstraint:: |
protected | property | The current user uid. | |
OwnOrAdminConstraint:: |
public | function |
Gets the account. Overrides OwnOrAdminConstraintInterface:: |
|
OwnOrAdminConstraint:: |
public | function |
Gets the permission. Overrides OwnOrAdminConstraintInterface:: |