function ContentExport::load_entity_list in Content Export YAML 8
Get all entity by entity
File
- src/
ContentExport.php, line 41
Class
- ContentExport
- Created by PhpStorm. User: USER Date: 11/13/18 Time: 2:04 PM
Namespace
Drupal\content_export_yamlCode
function load_entity_list($entity, $bundle, $ranges_nid = []) {
$id_label = \Drupal::entityTypeManager()
->getDefinition($entity)
->getKey('id');
// print_r(\Drupal::entityTypeManager()->getDefinition($entity)->getKeys());
$bundle_label = \Drupal::entityTypeManager()
->getDefinition($entity)
->getKey('bundle');
$factory = \Drupal::entityTypeManager()
->getStorage($entity)
->getQuery();
if ($bundle_label != "") {
$factory
->condition($bundle_label, $bundle);
}
if (!empty($ranges_nid) && isset($ranges_nid[0]) && isset($ranges_nid[1])) {
if (is_string($ranges_nid[0]) && is_string($ranges_nid[1])) {
if ($ranges_nid[0] == $ranges_nid[1]) {
$factory
->condition($id_label, $ranges_nid[1], '=');
}
else {
if (is_numeric($ranges_nid[0]) && is_numeric($ranges_nid[1])) {
$factory
->condition($id_label, $ranges_nid, 'BETWEEN');
}
else {
return [];
}
}
}
}
return $factory
->execute();
}