Gets translatable entities of a given type.
Additionally you can specify entity property conditions, pager and limit.
string $entity_type_id: Drupal entity type.
array $property_conditions: Entity properties. There is no value processing so caller must make sure the provided entity property exists for given entity type and its value is processed.
bool $pager: Flag to determine if pager will be used.
int $offset: Query range offset.
int $limit: Query range limit.
array ContentEntityInterface[] Array of translatable entities.
public static function getTranslatableEntities($entity_type_id, $property_conditions = array(), $pager = FALSE, $offset = 0, $limit = 0) {
$query = static::buildTranslatableEntitiesQuery($entity_type_id, $property_conditions);
if ($query) {
if ($pager) {
$query = $query
->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
->limit(\Drupal::config('tmgmt.settings')
->get('source_list_limit'));
}
elseif ($limit) {
$query
->range($offset, $limit);
}
else {
$query
->range(0, \Drupal::config('tmgmt.settings')
->get('source_list_limit'));
}
$result = $query
->execute();
$entity_ids = $result
->fetchCol();
$entities = array();
if (!empty($entity_ids)) {
$entities = \Drupal::entityTypeManager()
->getStorage($entity_type_id)
->loadMultiple($entity_ids);
}
return $entities;
}
return array();
}