public function LingotekConfigurationService::getEntityProfile in Lingotek Translation 8.2
Same name and namespace in other branches
- 8 src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 4.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.0.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.1.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.2.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.3.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.4.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.5.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.6.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.7.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
- 3.8.x src/LingotekConfigurationService.php \Drupal\lingotek\LingotekConfigurationService::getEntityProfile()
Determines the default Lingotek profile for the given entity.
@returns \Drupal\lingotek\LingotekProfileInterface The default profile.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
bool $provide_default: If TRUE, and the entity does not have a profile, will retrieve the default for this entity type and bundle. Defaults to TRUE.
Overrides LingotekConfigurationServiceInterface::getEntityProfile
File
- src/
LingotekConfigurationService.php, line 167
Class
- LingotekConfigurationService
- Service for managing lingotek configuration.
Namespace
Drupal\lingotekCode
public function getEntityProfile(ContentEntityInterface $entity, $provide_default = TRUE) {
$default_profile_id = $this
->getDefaultProfileId($entity
->getEntityTypeId(), $entity
->bundle(), $provide_default);
$profile_id = $default_profile_id;
if ($entity->lingotek_metadata !== NULL && $entity->lingotek_metadata->entity !== NULL) {
if ($entity->lingotek_metadata->entity
->getProfile() !== NULL) {
$profile_id = $entity->lingotek_metadata->entity
->getProfile();
}
else {
// If we have a NULL profile set on the entity and we don't want to
// provide a default, let's respect that.
$profile_id = $provide_default ? $profile_id : NULL;
}
}
$profile = $profile_id ? LingotekProfile::load($profile_id) : NULL;
if ($profile === NULL && $provide_default) {
$profile = $default_profile_id ? LingotekProfile::load($default_profile_id) : NULL;
}
if ($profile === NULL && $provide_default) {
// If we still didn't get a profile, return an agnostic profile that won't
// auto upload or auto download anything.
$profile = LingotekProfile::create([]);
}
// Allow other modules to alter the calculated profile.
\Drupal::moduleHandler()
->invokeAll('lingotek_content_entity_get_profile', [
$entity,
&$profile,
$provide_default,
]);
return $profile;
}