File.php in Drupal 10
File
core/modules/file/src/Plugin/migrate/source/d6/File.php
View source
<?php
namespace Drupal\file\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class File extends DrupalSqlBase {
protected $filePath;
protected $tempFilePath;
protected $isPublic;
public function query() {
return $this
->select('files', 'f')
->fields('f')
->condition('f.filepath', '/tmp%', 'NOT LIKE')
->orderBy('f.timestamp')
->orderBy('f.fid');
}
protected function initializeIterator() {
$site_path = $this->configuration['site_path'] ?? 'sites/default';
$this->filePath = $this
->variableGet('file_directory_path', $site_path . '/files') . '/';
$this->tempFilePath = $this
->variableGet('file_directory_temp', '/tmp') . '/';
$this->isPublic = $this
->variableGet('file_downloads', 1) == 1;
return parent::initializeIterator();
}
public function prepareRow(Row $row) {
$row
->setSourceProperty('file_directory_path', $this->filePath);
$row
->setSourceProperty('temp_directory_path', $this->tempFilePath);
$row
->setSourceProperty('is_public', $this->isPublic);
return parent::prepareRow($row);
}
public function fields() {
return [
'fid' => $this
->t('File ID'),
'uid' => $this
->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
'filename' => $this
->t('File name'),
'filepath' => $this
->t('File path'),
'filemime' => $this
->t('File MIME Type'),
'status' => $this
->t('The published status of a file.'),
'timestamp' => $this
->t('The time that the file was added.'),
'file_directory_path' => $this
->t('The Drupal files path.'),
'is_public' => $this
->t('TRUE if the files directory is public otherwise FALSE.'),
];
}
public function getIds() {
$ids['fid']['type'] = 'integer';
$ids['fid']['alias'] = 'f';
return $ids;
}
}
Classes
Name |
Description |
File |
Drupal 6 file source from database. |