public function LingotekProfileUsage::isUsedByContent in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 4.0.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.0.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.1.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.2.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.3.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.4.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.5.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.6.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.7.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
- 3.8.x src/LingotekProfileUsage.php \Drupal\lingotek\LingotekProfileUsage::isUsedByContent()
Check if a profile is used by content entities.
Parameters
\Drupal\lingotek\LingotekProfileInterface $profile: The profile being checked.
Return value
int Bitwise flag. Can include LingotekProfileUsageInterface::USED_BY_CONTENT or LingotekProfileUsageInterface::UNUSED.
Overrides LingotekProfileUsageInterface::isUsedByContent
File
- src/
LingotekProfileUsage.php, line 53
Class
- LingotekProfileUsage
- Service for checking Lingotek profiles usage.
Namespace
Drupal\lingotekCode
public function isUsedByContent(LingotekProfileInterface $profile) {
$entity_types = $this->lingotekConfiguration
->getEnabledEntityTypes();
$used = LingotekProfileUsageInterface::UNUSED;
foreach ($entity_types as $entity_type => $entity_type_definition) {
$entity_query = $this->entityQuery
->get($entity_type);
$entity_query
->condition('lingotek_profile', $profile
->id());
$result = $entity_query
->count()
->execute();
$used |= $result > 0 ? LingotekProfileUsageInterface::USED_BY_CONTENT : LingotekProfileUsageInterface::UNUSED;
}
return $used;
}