You are here

public function MigrateListFiles::__construct in Migrate 7.2

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

Constructor.

Parameters

$list_dirs: Array of directory paths that will be scanned for files. No trailing slash. For example: array( '/var/html_source/en/news', '/var/html_source/fr/news', '/var/html_source/zh/news', );

$base_dir: The base dir is the part of the path that will be excluded when making an ID for each file. To continue the example from above, you want base_dir to be = '/var/html_source', so that the files will have IDs in the format '/en/news/news_2011_03_4.html'.

$file_mask: (optional) Passed on and used to filter for certain types of files. Use a regular expression, for example '/(.*\.htm$|.*\.html$)/i' to match all .htm and .html files, case insensitive. Defaults to matching all files.

$options: Options that will be passed on to file_scan_directory(). See docs of that core Drupal function for more information.

MigrateContentParser $parser: Content parser class to use.

$get_contents: Whether to load the contents of files.

Overrides MigrateList::__construct

File

plugins/sources/files.inc, line 165
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

public function __construct($list_dirs, $base_dir, $file_mask = '//', $options = array(), MigrateContentParser $parser = NULL, $get_contents = TRUE) {
  if (!$parser) {
    $parser = new MigrateSimpleContentParser();
  }
  parent::__construct();
  $this->listDirs = $list_dirs;
  $this->baseDir = $base_dir;
  $this->fileMask = $file_mask;
  $this->directoryOptions = $options;
  $this->parser = $parser;
  $this->getContents = $get_contents;
}