Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / user / src / Plugin / migrate / source / d6 / UserPictureFile.php
1 <?php
2
3 namespace Drupal\user\Plugin\migrate\source\d6;
4
5 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
6 use Drupal\migrate\Row;
7
8 /**
9  * Drupal 6 user picture source from database.
10  *
11  * @MigrateSource(
12  *   id = "d6_user_picture_file",
13  *   source_module = "user"
14  * )
15  */
16 class UserPictureFile extends DrupalSqlBase {
17
18   /**
19    * The file directory path.
20    *
21    * @var string
22    */
23   protected $filePath;
24
25   /**
26    * The temporary file path.
27    *
28    * @var string
29    */
30   protected $tempFilePath;
31
32   /**
33    * {@inheritdoc}
34    */
35   public function query() {
36     $query = $this->select('users', 'u')
37       ->condition('u.picture', '', '<>')
38       ->fields('u', ['uid', 'picture']);
39     return $query;
40   }
41
42   /**
43    * {@inheritdoc}
44    */
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();
50   }
51
52   /**
53    * {@inheritdoc}
54    */
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);
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   public function fields() {
66     return [
67       'picture' => "Path to the user's uploaded picture.",
68       'filename' => 'The picture filename.',
69     ];
70   }
71   /**
72    * {@inheritdoc}
73    */
74   public function getIds() {
75     $ids['uid']['type'] = 'integer';
76     return $ids;
77   }
78
79 }