nextcloud_webdav_client-1.0.x-dev/src/NextCloudUserTokenStorageInterface.php

src/NextCloudUserTokenStorageInterface.php
<?php

namespace Drupal\nextcloud_webdav_client;

use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken;
use Drupal\user\UserInterface;

/**
 * Interface for NextCloud User Token storage.
 */
interface NextCloudUserTokenStorageInterface extends EntityStorageInterface {

  /**
   * Loads a token entity for a given user.
   *
   * @param \Drupal\user\UserInterface $user
   *   The user entity.
   *
   * @return \Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken|null
   *   The token entity, or NULL if not found.
   */
  public function loadByUser(UserInterface $user): ?NextCloudUserToken;

  /**
   * Loads a token entity for a given user ID.
   *
   * @param int $uid
   *   The user ID.
   *
   * @return \Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken|null
   *   The token entity, or NULL if not found.
   */
  public function loadByUserId(int $uid): ?NextCloudUserToken;

  /**
   * Creates a new token entity for a user.
   *
   * If a token already exists for the user, it will be updated instead.
   *
   * @param \Drupal\user\UserInterface $user
   *   The user entity.
   * @param array $token_data
   *   Token data containing:
   *   - access_token: The OAuth2 access token.
   *   - refresh_token: (optional) The OAuth2 refresh token.
   *   - token_expiry: (optional) The token expiry timestamp.
   *   - nextcloud_username: The NextCloud username.
   *
   * @return \Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken
   *   The created or updated token entity.
   */
  public function createForUser(UserInterface $user, array $token_data): NextCloudUserToken;

  /**
   * Updates an existing token entity with new data.
   *
   * @param \Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken $token
   *   The token entity to update.
   * @param array $token_data
   *   Token data to update.
   *
   * @return \Drupal\nextcloud_webdav_client\Entity\NextCloudUserToken
   *   The updated token entity.
   */
  public function updateToken(NextCloudUserToken $token, array $token_data): NextCloudUserToken;

  /**
   * Deletes a token entity for a given user.
   *
   * @param \Drupal\user\UserInterface $user
   *   The user entity.
   *
   * @return bool
   *   TRUE if a token was deleted, FALSE if no token existed.
   */
  public function deleteForUser(UserInterface $user): bool;

  /**
   * Checks if a user has a valid (non-expired) token.
   *
   * @param \Drupal\user\UserInterface $user
   *   The user entity.
   *
   * @return bool
   *   TRUE if user has a valid token, FALSE otherwise.
   */
  public function hasValidToken(UserInterface $user): bool;

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc