webex_client-1.0.5/src/Entity/Webex.php
src/Entity/Webex.php
<?php
declare(strict_types=1);
namespace Drupal\webex_client\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\webex_client\WebexInterface;
/**
* Defines the webex entity type.
*
* @ConfigEntityType(
* id = "webex",
* label = @Translation("webex"),
* label_collection = @Translation("webexes"),
* label_singular = @Translation("webex"),
* label_plural = @Translation("webexes"),
* label_count = @PluralTranslation(
* singular = "@count webex",
* plural = "@count webexes",
* ),
* handlers = {
* "list_builder" = "Drupal\webex_client\WebexListBuilder",
* "form" = {
* "add" = "Drupal\webex_client\Form\WebexForm",
* "edit" = "Drupal\webex_client\Form\WebexForm",
* "delete" = "Drupal\Core\Entity\EntityDeleteForm",
* },
* },
* config_prefix = "webex",
* admin_permission = "administer webex",
* links = {
* "collection" = "/admin/config/system/webex",
* "add-form" = "/admin/config/system/webex/add",
* "edit-form" = "/admin/config/system/webex/{webex}",
* "delete-form" = "/admin/config/system/webex/{webex}/delete",
* "make_default" = "/admin/config/system/webex/{webex}/make-default"
* },
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid",
* },
* config_export = {
* "id",
* "label",
* "scope",
* "expires_in",
* "token_type"
* },
* )
*/
class Webex extends ConfigEntityBase implements WebexInterface {
use WebexTokensTrait;
use WebexEncodeTrait;
/**
* {@inheritdoc}
*/
public function setClientId(string $client_id) {
$this->encodeKey('client_id', $client_id);
return $this;
}
/**
* {@inheritdoc}
*/
public function getClientId(): string {
return $this->decodeKey('client_id');
}
/**
* {@inheritdoc}
*/
public function setClientSecret(string $client_secret) {
$this->encodeKey('client_secret', $client_secret);
return $this;
}
/**
* {@inheritdoc}
*/
public function getClientSecret() {
return $this->decodeKey('client_secret');
}
/**
* {@inheritdoc}
*/
public function getScope() {
return $this->get('scope') ?? "";
}
/**
* {@inheritdoc}
*/
public function setScope(string $scope) {
return $this->set('scope', $scope);
}
/**
* {@inheritdoc}
*/
public function getExpiresIn() {
return $this->get('expires_in') ?? 0;
}
/**
* {@inheritdoc}
*/
public function setExpiresIn(int $expires_in = 0) {
return $this->set('expires_in', $expires_in);
}
/**
* {@inheritdoc}
*/
public function getRefreshTokenExpiresIn() {
return (int) $this->getTokens('refresh_token_expires_in') ?: 0;
}
/**
* {@inheritdoc}
*/
public function setRefreshTokenExpiresIn(int $value = 0) {
$this->setTokens('refresh_token_expires_in', (string) $value);
return $this;
}
/**
* {@inheritdoc}
*/
public function getTokenType() {
return $this->get('token_type') ?? "";
}
/**
* {@inheritdoc}
*/
public function setTokenType(string $token_type) {
return $this->set('token_type', $token_type);
}
/**
* {@inheritdoc}
*/
public function isDefault(): bool {
$value = (int) $this->getTokens('default');
return (bool) $value;
}
/**
* {@inheritdoc}
*/
public function setDefault(bool $default = TRUE) {
$this->setTokens('default', (string) ($default ? 1 : 0));
return $this;
}
/**
* {@inheritdoc}
*/
public function setCode(string $code) {
$this->setTokens('code', $code);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCode() {
return $this->getTokens('code') ?? "";
}
/**
* {@inheritdoc}
*/
public function setAccessToken(string $access_token) {
$this->setTokens('access_token', $access_token);
return $this;
}
/**
* {@inheritdoc}
*/
public function getAccessToken() {
return $this->getTokens('access_token') ?? "";
}
/**
* {@inheritdoc}
*/
public function setRefreshToken(string $refresh_token) {
$this->setTokens('refresh_token', $refresh_token);
return $this;
}
/**
* {@inheritdoc}
*/
public function getRefreshToken() {
return $this->getTokens('refresh_token') ?? "";
}
}
