You are here

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

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

Sets the default Lingotek profile for the given entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

string $profile_id: The profile id.

bool $save: Indicates if we should save the entity after setting the value.

Overrides LingotekConfigurationServiceInterface::setProfile

File

src/LingotekConfigurationService.php, line 239

Class

LingotekConfigurationService
Service for managing lingotek configuration.

Namespace

Drupal\lingotek

Code

public function setProfile(ContentEntityInterface &$entity, $profile_id, $save = TRUE) {

  // ToDo: deprecate second argument?
  // If it's the first save of this content, we don't have an ID yet. Wait for
  // saving yet.
  if (!$entity->lingotek_metadata->entity) {
    $entity->lingotek_metadata->entity = LingotekContentMetadata::create();
  }
  $entity->lingotek_metadata->entity
    ->setProfile($profile_id);
  $entity->lingotek_metadata->entity
    ->save();
}