webex_client-1.0.5/src/WebexHelper.php

src/WebexHelper.php
<?php

namespace Drupal\webex_client;

use Drupal\webex_client\Entity\Webex;

/**
 * This class provides helper methods for managing Webex entities.
 */
class WebexHelper {

  /**
   * Retrieves the default Webex entity configuration.
   *
   * @return \Drupal\webex_client\Entity\Webex|null
   *   Returns the default Webex entity if found, otherwise NULL.
   */
  public static function defaultConfig(): ?Webex {
    $webexs = Webex::loadMultiple();
    if ($webexs) {
      $result = array_filter($webexs, static fn(Webex $webex) => $webex->isDefault());
      if ($result) {
        return reset($result);
      }
    }
    return NULL;
  }

  /**
   * Returns the access token for the default Webex entity.
   *
   * @return string
   *   The access token for the default Webex entity.
   */
  public static function accessToken(): string {
    if ($webex = self::defaultConfig()) {
      return $webex->getTokenType() . " " . $webex->getAccessToken();
    }
    return "";
  }

}

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

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