You are here

public function LingotekProfileUsage::isUsedByContentSettings in Lingotek Translation 8.2

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

Check if a profile is configured to be used by content entities.

Parameters

\Drupal\lingotek\LingotekProfileInterface $profile: The profile being checked.

Return value

int Bitwise flag. Can include LingotekProfileUsageInterface::USED_BY_SETTINGS or LingotekProfileUsageInterface::UNUSED.

Overrides LingotekProfileUsageInterface::isUsedByContentSettings

File

src/LingotekProfileUsage.php, line 134

Class

LingotekProfileUsage
Service for checking Lingotek profiles usage.

Namespace

Drupal\lingotek

Code

public function isUsedByContentSettings(LingotekProfileInterface $profile) {
  $entity_types = $this->lingotekConfiguration
    ->getEnabledEntityTypes();
  $used = LingotekProfileUsageInterface::UNUSED;
  foreach ($entity_types as $entity_type_id => $entity_type_definition) {
    $bundles = $this->entityTypeBundleInfo
      ->getBundleInfo($entity_type_id);
    foreach ($bundles as $bundle_id => $bundle_definition) {
      $config_profile = $this->lingotekConfiguration
        ->getDefaultProfileId($entity_type_id, $bundle_id);
      if ($config_profile === $profile
        ->id()) {
        $used |= LingotekProfileUsageInterface::USED_BY_SETTINGS;
      }
    }
  }
  return $used;
}