3 namespace Drupal\user\Plugin\migrate\source\d6;
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
9 * Drupal 6 user picture source from database.
12 * id = "d6_user_picture_file",
13 * source_module = "user"
16 class UserPictureFile extends DrupalSqlBase {
19 * The file directory path.
26 * The temporary file path.
30 protected $tempFilePath;
35 public function query() {
36 $query = $this->select('users', 'u')
37 ->condition('u.picture', '', '<>')
38 ->fields('u', ['uid', 'picture']);
45 public function initializeIterator() {
46 $site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
47 $this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
48 $this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
49 return parent::initializeIterator();
55 public function prepareRow(Row $row) {
56 $row->setSourceProperty('filename', basename($row->getSourceProperty('picture')));
57 $row->setSourceProperty('file_directory_path', $this->filePath);
58 $row->setSourceProperty('temp_directory_path', $this->tempFilePath);
59 return parent::prepareRow($row);
65 public function fields() {
67 'picture' => "Path to the user's uploaded picture.",
68 'filename' => 'The picture filename.',
74 public function getIds() {
75 $ids['uid']['type'] = 'integer';