You are here

class SmartlingConfigManager in TMGMT Translator Smartling 8.4

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

Class SmartlingConfigManager.

Hierarchy

Expanded class hierarchy of SmartlingConfigManager

1 file declares its use of SmartlingConfigManager
BufferLogger.php in src/Logger/BufferLogger.php
1 string reference to 'SmartlingConfigManager'
tmgmt_smartling.services.yml in ./tmgmt_smartling.services.yml
tmgmt_smartling.services.yml
1 service uses SmartlingConfigManager
tmgmt_smartling.smartling_config_manager in ./tmgmt_smartling.services.yml
\Drupal\tmgmt_smartling\Smartling\ConfigManager\SmartlingConfigManager

File

src/Smartling/ConfigManager/SmartlingConfigManager.php, line 16
FirebaseConfigManager.

Namespace

Drupal\tmgmt_smartling\Smartling\ConfigManager
View source
class SmartlingConfigManager {

  /**
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * SmartlingConfigManager constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   */
  public function __construct(ConfigFactoryInterface $configFactory) {
    $this->configFactory = $configFactory;
  }

  /**
   * Returns array of available smartling providers.
   *
   * @return array
   */
  public function getAvailableConfigs() {
    $configs = [];
    $translator_ids = $this->configFactory
      ->listAll('tmgmt.translator');
    foreach ($translator_ids as $id) {
      $config = $this->configFactory
        ->get($id);
      if ($config
        ->get('plugin') === 'smartling') {
        $configs[] = $config;
      }
    }
    return $configs;
  }

  /**
   * Returns smartling provider config by project id.
   *
   * @param $projectId
   * @return Config|NULL
   */
  public function getConfigByProjectId($projectId) {
    $configs = $this
      ->getAvailableConfigs();
    $result = NULL;
    foreach ($configs as $config) {
      $provider_settings = $config
        ->get('settings');
      if (!empty($provider_settings["project_id"]) && $provider_settings["project_id"] == $projectId) {
        $result = $config;
        break;
      }
    }
    return $result;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SmartlingConfigManager::$configFactory protected property
SmartlingConfigManager::getAvailableConfigs public function Returns array of available smartling providers. 1
SmartlingConfigManager::getConfigByProjectId public function Returns smartling provider config by project id.
SmartlingConfigManager::__construct public function SmartlingConfigManager constructor.