You are here

class ConnectorInfo in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 src/Smartling/ConnectorInfo.php \Drupal\tmgmt_smartling\Smartling\ConnectorInfo

Class ConnectorInfo @package Drupal\tmgmt_smartling\Smartling

Hierarchy

Expanded class hierarchy of ConnectorInfo

3 files declare their use of ConnectorInfo
BufferLogger.php in src/Logger/BufferLogger.php
ConnectorInfoTest.php in tests/src/Kernel/ConnectorInfoTest.php
SmartlingTranslator.php in src/Plugin/tmgmt/Translator/SmartlingTranslator.php
Contains \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator.

File

src/Smartling/ConnectorInfo.php, line 17
SmartlingApiFactory.php.

Namespace

Drupal\tmgmt_smartling\Smartling
View source
class ConnectorInfo {

  /**
   * Returns module name.
   *
   * @return string
   */
  public static function getLibName() {
    return 'drupal-tmgmt-connector';
  }

  /**
   * Returns module version.
   *
   * @param string $name
   * @param string $default
   * @return string
   */
  public static function getLibVersion($name = 'tmgmt_smartling', $default = 'unknown') {
    try {
      $info = \Drupal::service('extension.list.module')
        ->getExtensionInfo($name);
    } catch (UnknownExtensionException $e) {
      $info = [
        'version' => $default,
      ];
    }
    $client_version = $default;
    if (!empty($info['version'])) {
      $client_version = $info['version'];
    }
    return $client_version;
  }
  public static function getDependenciesVersionsAsString() {
    $result = [];
    $dependencies = [
      'tmgmt_extension_suit',
      'tmgmt',
    ];
    foreach ($dependencies as $dependency) {
      $result[] = "{$dependency}/" . self::getLibVersion($dependency);
    }
    return implode(' ', $result);
  }

  /**
   * Set up current client id and version.
   */
  public static function setUpCurrentClientInfo() {
    BaseApiAbstract::setCurrentClientId(self::getLibName());
    BaseApiAbstract::setCurrentClientVersion(self::getLibVersion());
    BaseApiAbstract::setCurrentClientUserAgentExtension(self::getDependenciesVersionsAsString());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConnectorInfo::getDependenciesVersionsAsString public static function
ConnectorInfo::getLibName public static function Returns module name.
ConnectorInfo::getLibVersion public static function Returns module version.
ConnectorInfo::setUpCurrentClientInfo public static function Set up current client id and version.