You are here

function DBManager::load_exported_all in Content Export YAML 8

File

modules/manager_content_export_yaml/src/DBManager.php, line 62

Class

DBManager

Namespace

Drupal\content_export_yaml

Code

function load_exported_all() {
  $config = \Drupal::config('content_export_yaml.contentexportsetting');
  $themes_str = $config
    ->get('path_export_content_folder');
  $items = [];
  if ($themes_str) {
    $result = $this
      ->listFolderFiles(DRUPAL_ROOT . $themes_str);
    foreach ($result as $key => $item_entity_type) {
      foreach ($item_entity_type as $key => $item_bundle) {
        foreach ($item_bundle as $key => $item) {
          $items[] = $item;
          if (is_array($item) && !empty($item) && isset($item['entity'])) {
            $entity_object = $item['entity'];
            if (is_object($entity_object)) {
              $entity = $entity_object
                ->getEntityTypeId();
              $dbstatus = $this
                ->is_exist($entity_object
                ->id(), $entity, $entity_object
                ->bundle());
              if (empty($dbstatus)) {
                $fields = array(
                  'entity_id' => $entity_object
                    ->id(),
                  'entity_type' => $entity,
                  'bundle' => $entity_object
                    ->bundle(),
                  'label' => $entity_object
                    ->label(),
                  'file' => $item['path'],
                );
                $this
                  ->insert($fields);
              }
            }
          }
        }
      }
    }
  }
  return $items;
}