You are here

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

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\Constraint
View 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

Namesort descending Modifiers Type Description Overrides
OwnOrAdminConstraint::$account protected property The current user uid.
OwnOrAdminConstraint::$message public property
OwnOrAdminConstraint::$permission protected property The current user uid.
OwnOrAdminConstraint::getAccount public function Gets the account. Overrides OwnOrAdminConstraintInterface::getAccount
OwnOrAdminConstraint::getPermission public function Gets the permission. Overrides OwnOrAdminConstraintInterface::getPermission