You are here

public function ManageExport::exportFrom in Content Export YAML 8

4 calls to ManageExport::exportFrom()
ManageExport::exportAll in src/ManageExport.php
ManageExport::exportBlockAll in src/ManageExport.php
ManageExport::exportNodeAll in src/ManageExport.php
ManageExport::exportTermAll in src/ManageExport.php

File

src/ManageExport.php, line 37

Class

ManageExport

Namespace

Drupal\content_export_yaml

Code

public function exportFrom($entity, $bundle, $options = []) {
  $rangenid = [];
  if (isset($options['range']) && isset($options['range'][0]) && isset($options['range'][1])) {
    $rangenid[0] = $options['range'][0];
    $rangenid[1] = $options['range'][1];
  }
  $object_list = $this->func
    ->load_entity_list($entity, $bundle, $rangenid);
  $id_label = \Drupal::entityTypeManager()
    ->getDefinition($entity)
    ->getKey('id');
  $status_list = [];
  foreach ($object_list as $id) {
    $object = \Drupal::entityTypeManager()
      ->getStorage($entity)
      ->load($id);
    if (is_object($object)) {
      $status = $this->func
        ->exportWithPath($object, $entity, $options);
      $status_list[] = [
        'status' => $status,
        'label' => $object
          ->label(),
        $id_label => $object
          ->id(),
      ];
    }
  }
  return $status_list;
}