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"
15 class UserPictureFile extends DrupalSqlBase {
18 * The file directory path.
25 * The temporary file path.
29 protected $tempFilePath;
34 public function query() {
35 $query = $this->select('users', 'u')
36 ->condition('u.picture', '', '<>')
37 ->fields('u', ['uid', 'picture']);
44 public function initializeIterator() {
45 $site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
46 $this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
47 $this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
48 return parent::initializeIterator();
54 public function prepareRow(Row $row) {
55 $row->setSourceProperty('filename', basename($row->getSourceProperty('picture')));
56 $row->setSourceProperty('file_directory_path', $this->filePath);
57 $row->setSourceProperty('temp_directory_path', $this->tempFilePath);
58 return parent::prepareRow($row);
64 public function fields() {
66 'picture' => "Path to the user's uploaded picture.",
67 'filename' => 'The picture filename.',
73 public function getIds() {
74 $ids['uid']['type'] = 'integer';