You are here

public function MigrateFileUri::processFile in Migrate 7.2

Implementation of MigrateFileInterface::processFiles().

Parameters

$value: The URI or local filespec of a file to be imported.

$owner: User ID (uid) to be the owner of the file.

Return value

object The file entity being created or referenced.

Overrides MigrateFile::processFile

File

plugins/destinations/file.inc, line 457
Support for file entity as destination. Note that File Fields have their own destination in fields.inc

Class

MigrateFileUri
Handle cases where we're handed a URI, or local filespec, representing a file to be imported to Drupal.

Code

public function processFile($value, $owner) {

  // Identify the full path to the source file
  if (!empty($this->sourceDir)) {
    $this->sourcePath = rtrim($this->sourceDir, "/\\") . '/' . ltrim($value, "/\\");
  }
  else {
    $this->sourcePath = $value;
  }
  if (empty($this->destinationFile)) {
    $path = explode('?', $this->sourcePath);
    $this->destinationFile = basename($path[0]);
  }

  // MigrateFile has most of the smarts - the key is that it will call back
  // to our copyFile() implementation.
  $file = parent::processFile($value, $owner);
  return $file;
}