class UserEmailVerificationNeeded in User email verification 8
Defines the UserEmailVerificationNeeded context service.
Cache context ID: 'user_email_verification_needed'.
Hierarchy
- class \Drupal\user_email_verification\Cache\Context\UserEmailVerificationNeeded implements CacheContextInterface
Expanded class hierarchy of UserEmailVerificationNeeded
1 string reference to 'UserEmailVerificationNeeded'
1 service uses UserEmailVerificationNeeded
File
- src/Cache/ Context/ UserEmailVerificationNeeded.php, line 15 
Namespace
Drupal\user_email_verification\Cache\ContextView source
class UserEmailVerificationNeeded implements CacheContextInterface {
  /**
   * User email verification helper service.
   *
   * @var \Drupal\user_email_verification\UserEmailVerificationInterface
   */
  protected $userEmailVerification;
  /**
   * The current active user.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;
  /**
   * Constructs a new object.
   *
   * @param \Drupal\user_email_verification\UserEmailVerificationInterface $user_email_verification_service
   *   User email verification helper service.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   The current active user.
   */
  public function __construct(UserEmailVerificationInterface $user_email_verification_service, AccountProxyInterface $current_user) {
    $this->userEmailVerification = $user_email_verification_service;
    $this->currentUser = $current_user;
  }
  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('User Email verification needed');
  }
  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->currentUser
      ->isAuthenticated() && $this->userEmailVerification
      ->isVerificationNeeded() ? 'uev-needed' : '';
  }
  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata($type = NULL) {
    $cacheability = new CacheableMetadata();
    $cacheability
      ->addCacheContexts([
      'user',
    ]);
    return $cacheability;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| UserEmailVerificationNeeded:: | protected | property | The current active user. | |
| UserEmailVerificationNeeded:: | protected | property | User email verification helper service. | |
| UserEmailVerificationNeeded:: | public | function | Gets the cacheability metadata for the context. Overrides CacheContextInterface:: | |
| UserEmailVerificationNeeded:: | public | function | Returns the string representation of the cache context. Overrides CacheContextInterface:: | |
| UserEmailVerificationNeeded:: | public static | function | Returns the label of the cache context. Overrides CacheContextInterface:: | |
| UserEmailVerificationNeeded:: | public | function | Constructs a new object. | 
