You are here

public function ContentSyncManager::generateImportQueue in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x src/ContentSyncManager.php \Drupal\content_sync\ContentSyncManager::generateImportQueue()

Parameters

$file_names:

$directory:

Return value

array

File

src/ContentSyncManager.php, line 67

Class

ContentSyncManager

Namespace

Drupal\content_sync

Code

public function generateImportQueue($file_names, $directory) {
  $queue = [];
  foreach ($file_names as $file) {
    $ids = explode('.', $file);
    list($entity_type_id, $bundle, $uuid) = $ids;
    $file_path = $directory . "/" . $entity_type_id . "/" . $bundle . "/" . $file . ".yml";
    if (!file_exists($file_path) || !$this
      ->isValidFilename($file)) {
      continue;
    }
    $content = file_get_contents($file_path);
    $format = $this->contentImporter
      ->getFormat();
    $decoded_entity = $this->serializer
      ->decode($content, $format);
    $decoded_entities[$file] = $decoded_entity;
  }
  if (!empty($decoded_entities)) {
    $resolver = new ImportQueueResolver();
    $queue = $resolver
      ->resolve($decoded_entities);
  }
  return $queue;
}