You are here

public function LingotekConfigurationService::setConfigProfile in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  2. 4.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  3. 3.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  4. 3.1.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  5. 3.2.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  6. 3.3.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  7. 3.5.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  8. 3.6.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  9. 3.7.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()
  10. 3.8.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::setConfigProfile()

File

src/LingotekConfigurationService.php, line 265

Class

LingotekConfigurationService
Service for managing lingotek configuration.

Namespace

Drupal\lingotek

Code

public function setConfigProfile($mapper_id, $profile_id, $save = TRUE) {

  /** @var \Drupal\config_translation\ConfigMapperManager $mapper_manager */
  $mapper_manager = \Drupal::service('plugin.manager.config_translation.mapper');
  $mappers = $mapper_manager
    ->getMappers();
  $mapper = $mappers[$mapper_id];
  $config_names = $mapper
    ->getConfigNames();
  foreach ($config_names as $config_name) {
    $metadata = LingotekConfigMetadata::loadByConfigName($config_name);
    $metadata
      ->setProfile($profile_id);
    $metadata
      ->save();
  }
  return $mapper;
}