You are here

protected function MigrateListFiles::getIDsFromFiles in Migrate 6.2

Same name and namespace in other branches
  1. 7.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 136
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) {
    $contents = file_get_contents($file->uri);
    $this->parser
      ->setContent($contents);
    if ($this->parser
      ->getChunkCount() > 1) {
      foreach ($this->parser
        ->getChunkIDs() as $chunk_id) {
        $ids[] = str_replace($this->baseDir, '', (string) $file->uri) . MIGRATE_CHUNK_SEPARATOR . $chunk_id;
      }
    }
    else {
      $ids[] = str_replace($this->baseDir, '', (string) $file->uri);
    }
  }
  return array_unique($ids);
}