public function MigrateItemFile::getItem in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/files.inc \MigrateItemFile::getItem()
Return an object representing a file or piece thereof.
Parameters
$id: The file id, which is the file URI.
Return value
object The item object for migration.
Overrides MigrateItem::getItem
File
- plugins/
sources/ files.inc, line 290 - Support for migration from files sources.
Class
- MigrateItemFile
- Implementation of MigrateItem, for retrieving a file from the file system based on source directory and an ID provided by a MigrateList class.
Code
public function getItem($id) {
$pieces = explode(MIGRATE_CHUNK_SEPARATOR, $id);
$item_uri = $this->baseDir . $pieces[0];
$chunk = !empty($pieces[1]) ? $pieces[1] : '';
// Get the file data at the specified URI
$data = $this
->loadFile($item_uri);
if (is_string($data)) {
$this->parser
->setContent($data, $pieces[0]);
$return = new stdClass();
$return->filedata = $this->parser
->getChunk($chunk);
return $return;
}
else {
if ($data === TRUE) {
$return = new stdClass();
return $return;
}
else {
$migration = Migration::currentMigration();
$message = t('Loading of !objecturi failed:', array(
'!objecturi' => $item_uri,
));
$migration
->getMap()
->saveMessage(array(
$id,
), $message, MigrationBase::MESSAGE_ERROR);
return NULL;
}
}
}