You are here

protected function MigrateListFiles::getIDsFromFiles in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/files.inc \MigrateListFiles::getIDsFromFiles()

Given an array generated from file_scan_directory(), parse out the IDs for processing and return them as an array.

1 call to MigrateListFiles::getIDsFromFiles()
MigrateListFiles::getIdList in plugins/sources/files.inc
Retrieve a list of files based on parameters passed for the migration.

File

plugins/sources/files.inc, line 212
Support for migration from files sources.

Class

MigrateListFiles
Implementation of MigrateList, for retrieving a list of IDs to be migrated from a directory listing. Each item is a file, it's ID is the path.

Code

protected function getIDsFromFiles(array $files) {
  $ids = array();
  foreach ($files as $file) {
    $file_base_id = str_replace($this->baseDir, '', (string) $file->uri);
    if ($this->getContents) {
      $contents = file_get_contents($file->uri);
      $this->parser
        ->setContent($contents, $file_base_id);
      if ($this->parser->alwaysUseChunkIDs || $this->parser
        ->getChunkCount() > 1) {
        foreach ($this->parser
          ->getChunkIDs() as $chunk_id) {
          $ids[] = $file_base_id . MIGRATE_CHUNK_SEPARATOR . $chunk_id;
        }
      }
      else {
        $ids[] = $file_base_id;
      }
    }
    else {
      $ids[] = $file_base_id;
    }
  }
  return array_unique($ids);
}